Difference between revisions of "使用到的C++11特性"

From KlayGE
Jump to: navigation, search
Line 5: Line 5:
 
{| class="wikitable"
 
{| class="wikitable"
 
|-
 
|-
! 语言功能 !! 宏 !! MSVC !! GCC !! 替代方案
+
! 语言功能 !! 宏 !! MSVC !! GCC !! Clang !! 替代方案
 
|-  
 
|-  
| Allowing move constructors to throw [noexcept] || KLAYGE_CXX11_CORE_NOEXCEPT_SUPPORT || {{Yes}}14.0 || {{Yes}}4.6 || throw()
+
| Allowing move constructors to throw [noexcept] || KLAYGE_CXX11_CORE_NOEXCEPT_SUPPORT || {{Yes}}14.0 || {{Yes}}4.6 || {{Yes}}3.0 || throw()
 
|-
 
|-
| Declared type of an expression || KLAYGE_CXX11_CORE_DECLTYPE_SUPPORT || {{Yes}}10.0 || {{Yes}}4.3 || Boost.Typeof
+
| Declared type of an expression || KLAYGE_CXX11_CORE_DECLTYPE_SUPPORT || {{Yes}}10.0 || {{Yes}}4.3 || {{Yes}}3.0 || Boost.Typeof
 
|-
 
|-
| Extern templates || KLAYGE_CXX11_CORE_EXTERN_TEMPLATES_SUPPORT || {{Yes}}9.0 || {{Yes}}4.3 ||
+
| Extern templates || KLAYGE_CXX11_CORE_EXTERN_TEMPLATES_SUPPORT || {{Yes}}9.0 || {{Yes}}4.3 || {{Yes}}3.0 ||
 
|-
 
|-
| Explicit virtual overrides || KLAYGE_CXX11_CORE_OVERRIDE_SUPPORT || {{Yes}}11.0 || {{Yes}}4.7 || #define
+
| Explicit virtual overrides || KLAYGE_CXX11_CORE_OVERRIDE_SUPPORT || {{Yes}}11.0 || {{Yes}}4.7 || {{Yes}}3.0 || #define
 
|-
 
|-
| Generalized constant expressions || KLAYGE_CXX11_CORE_CONSTEXPR_SUPPORT || {{No}}No || {{Yes}}4.6 ||
+
| Generalized constant expressions || KLAYGE_CXX11_CORE_CONSTEXPR_SUPPORT || {{No}}No || {{Yes}}4.6 || {{Yes}}3.0 ||
 
|-
 
|-
| Null pointer constant || KLAYGE_CXX11_CORE_NULLPTR_SUPPORT || {{Yes}}10.0 || {{Yes}}4.6 || 自己实现的null_ptr
+
| Null pointer constant || KLAYGE_CXX11_CORE_NULLPTR_SUPPORT || {{Yes}}10.0 || {{Yes}}4.6 || {{Yes}}3.0 || 自己实现的null_ptr
 
|-
 
|-
| Range-based for || KLAYGE_CXX11_CORE_FOREACH_SUPPORT || {{Yes}}11.0 || {{Yes}}4.6 || Boost.Foreach
+
| Range-based for || KLAYGE_CXX11_CORE_FOREACH_SUPPORT || {{Yes}}11.0 || {{Yes}}4.6 || {{Yes}}3.0 || Boost.Foreach
 
|-
 
|-
| Rvalue references || KLAYGE_CXX11_CORE_RVALUE_REFERENCES_SUPPORT || {{Yes}}11.0 || {{Yes}}4.3 || Boost.Move
+
| Rvalue references || KLAYGE_CXX11_CORE_RVALUE_REFERENCES_SUPPORT || {{Yes}}11.0 || {{Yes}}4.3 || {{Yes}}3.0 || Boost.Move
 
|-
 
|-
| Static assertions || KLAYGE_CXX11_CORE_STATIC_ASSERT_SUPPORT || {{Yes}}10.0 || {{Yes}}4.3 || Boost.StaticAssert
+
| Static assertions || KLAYGE_CXX11_CORE_STATIC_ASSERT_SUPPORT || {{Yes}}10.0 || {{Yes}}4.3 || {{Yes}}3.0 || Boost.StaticAssert
 
|-
 
|-
| Strongly-typed enums || KLAYGE_CXX11_CORE_STRONGLY_TYPED_ENUMS_SUPPORT || {{Yes}}11.0 || {{Yes}}4.4 || C++98的enum
+
| Strongly-typed enums || KLAYGE_CXX11_CORE_STRONGLY_TYPED_ENUMS_SUPPORT || {{Yes}}11.0 || {{Yes}}4.4 || {{Yes}}3.0 || C++98的enum
 
|-
 
|-
| Variadic templates || KLAYGE_CXX11_CORE_VARIADIC_TEMPLATES || {{Yes}}12.0 || {{Yes}}4.3 ||
+
| Variadic templates || KLAYGE_CXX11_CORE_VARIADIC_TEMPLATES || {{Yes}}12.0 || {{Yes}}4.3 || {{Yes}}3.0 ||
 
|}
 
|}
 
== C++11核心语言功能:并行 ==
 
== C++11核心语言功能:并行 ==
Line 37: Line 37:
 
{| class="wikitable"
 
{| class="wikitable"
 
|-
 
|-
! 名称 !! 宏 !! MSVC !! GCC !! 替代方案
+
! 名称 !! 宏 !! MSVC !! GCC !! Clang !! 替代方案
 
|-
 
|-
| algorithm (只用了copy_if) || KLAYGE_CXX11_LIBRARY_ALGORITHM_SUPPORT || {{Yes}}11.0 || {{Yes}}4.3 || Self-implemented copy_if
+
| algorithm (只用了copy_if) || KLAYGE_CXX11_LIBRARY_ALGORITHM_SUPPORT || {{Yes}}11.0 || {{Yes}}4.3 || {{Yes}}3.0 || Self-implemented copy_if
 
|-
 
|-
| array || KLAYGE_CXX11_LIBRARY_ARRAY_SUPPORT || {{Yes}}10.0 || {{Yes}}4.3 || Boost.Array
+
| array || KLAYGE_CXX11_LIBRARY_ARRAY_SUPPORT || {{Yes}}10.0 || {{Yes}}4.3 || {{Yes}}3.0 || Boost.Array
 
|-
 
|-
| atomic || KLAYGE_CXX11_LIBRARY_ATOMIC_SUPPORT || {{Yes}}11.0 || {{Yes}}4.4 || Boost.Atomic
+
| atomic || KLAYGE_CXX11_LIBRARY_ATOMIC_SUPPORT || {{Yes}}11.0 || {{Yes}}4.4 || {{Yes}}3.0 || Boost.Atomic
 
|-
 
|-
| chrono || KLAYGE_CXX11_LIBRARY_CHRONO_SUPPORT || {{Yes}}11.0 || {{Yes}}4.4 (必须有_GLIBCXX_HAS_GTHREADS) || Boost.Chrono
+
| chrono || KLAYGE_CXX11_LIBRARY_CHRONO_SUPPORT || {{Yes}}11.0 || {{Yes}}4.4 (必须有_GLIBCXX_HAS_GTHREADS) || {{Yes}}3.0 || Boost.Chrono
 
|-
 
|-
| cstdint || KLAYGE_CXX11_LIBRARY_CSTDINT_SUPPORT || {{Yes}}10.0 || {{Yes}}4.3 || Boost.Integer
+
| cstdint || KLAYGE_CXX11_LIBRARY_CSTDINT_SUPPORT || {{Yes}}10.0 || {{Yes}}4.3 || {{Yes}}3.0 || Boost.Integer
 
|-
 
|-
| functional || KLAYGE_CXX11_LIBRARY_FUNCTIONAL_SUPPORT || {{Yes}}10.0 || {{Yes}}4.3 || Boost.Functional
+
| functional || KLAYGE_CXX11_LIBRARY_FUNCTIONAL_SUPPORT || {{Yes}}10.0 || {{Yes}}4.3 || {{Yes}}3.0 || Boost.Functional
 
|-
 
|-
| mem_fn || KLAYGE_CXX11_LIBRARY_MEM_FN_SUPPORT || {{Yes}}12.0 || {{No}}No || Boost.MemFn
+
| mem_fn || KLAYGE_CXX11_LIBRARY_MEM_FN_SUPPORT || {{Yes}}12.0 || {{No}}No || {{No}}No || Boost.MemFn
 
|-
 
|-
| random || KLAYGE_CXX11_LIBRARY_RANDOM_SUPPORT || {{Yes}}10.0 || {{Yes}}4.3 || Boost.Random
+
| random || KLAYGE_CXX11_LIBRARY_RANDOM_SUPPORT || {{Yes}}10.0 || {{Yes}}4.3 || {{Yes}}3.0 || Boost.Random
 
|-
 
|-
| regex || KLAYGE_CXX11_LIBRARY_REGEX_SUPPORT || {{Yes}}10.0 || {{Yes}}4.9 || Boost.Regex
+
| regex || KLAYGE_CXX11_LIBRARY_REGEX_SUPPORT || {{Yes}}10.0 || {{Yes}}4.9 || {{Yes}}3.0 || Boost.Regex
 
|-
 
|-
| smart_ptr || KLAYGE_CXX11_LIBRARY_SMART_PTR_SUPPORT || {{Yes}}11.0 || {{Yes}}4.3 || Boost.SmartPtr
+
| smart_ptr || KLAYGE_CXX11_LIBRARY_SMART_PTR_SUPPORT || {{Yes}}11.0 || {{Yes}}4.3 || {{Yes}}3.0 || Boost.SmartPtr
 
|-
 
|-
| system_error || KLAYGE_CXX11_LIBRARY_SYSTEM_ERROR_SUPPORT || {{Yes}}10.0 || {{Yes}}4.4 || Boost.System
+
| system_error || KLAYGE_CXX11_LIBRARY_SYSTEM_ERROR_SUPPORT || {{Yes}}10.0 || {{Yes}}4.4 || {{Yes}}3.0 || Boost.System
 
|-
 
|-
| thread || KLAYGE_CXX11_LIBRARY_THREAD_SUPPORT || {{Yes}}11.0 || {{Yes}}4.4 (必须有_GLIBCXX_HAS_GTHREADS) || Boost.Thread
+
| thread || KLAYGE_CXX11_LIBRARY_THREAD_SUPPORT || {{Yes}}11.0 || {{Yes}}4.4 (必须有_GLIBCXX_HAS_GTHREADS) || {{Yes}}3.0 || Boost.Thread
 
|-
 
|-
| tuple || KLAYGE_CXX11_LIBRARY_TUPLE_SUPPORT || {{Yes}}10.0 || {{Yes}}4.3 || Boost.Tuple
+
| tuple || KLAYGE_CXX11_LIBRARY_TUPLE_SUPPORT || {{Yes}}10.0 || {{Yes}}4.3 || {{Yes}}3.0 || Boost.Tuple
 
|-
 
|-
| type_traits || KLAYGE_CXX11_LIBRARY_TYPE_TRAITS_SUPPORT || {{Yes}}10.0 || {{Yes}}4.3 || Boost.TypeTraits
+
| type_traits || KLAYGE_CXX11_LIBRARY_TYPE_TRAITS_SUPPORT || {{Yes}}10.0 || {{Yes}}4.3 || {{Yes}}3.0 || Boost.TypeTraits
 
|-
 
|-
| unordered || KLAYGE_CXX11_LIBRARY_UNORDERED_SUPPORT || {{Yes}}10.0 || {{Yes}}4.3 || Boost.Unordered
+
| unordered || KLAYGE_CXX11_LIBRARY_UNORDERED_SUPPORT || {{Yes}}10.0 || {{Yes}}4.3 || {{Yes}}3.0 || Boost.Unordered
 
|}
 
|}
  
Line 73: Line 73:
 
{| class="wikitable"
 
{| class="wikitable"
 
|-
 
|-
! 名称 !! 宏 !! MSVC !! GCC !! 替代方案
+
! 名称 !! 宏 !! MSVC !! GCC !! Clang !! 替代方案
 
|-
 
|-
| filesystem || KLAYGE_TR2_LIBRARY_FILESYSTEM_V2_SUPPORT || {{Yes}}11.0 || {{No}}No || Boost.FileSystem
+
| filesystem || KLAYGE_TR2_LIBRARY_FILESYSTEM_V2_SUPPORT || {{Yes}}11.0 || {{No}}No || {{No}}No || Boost.FileSystem
 
|-
 
|-
| filesystem || KLAYGE_TR2_LIBRARY_FILESYSTEM_V3_SUPPORT || {{Yes}}14.0 || {{No}}No || Boost.FileSystem
+
| filesystem || KLAYGE_TR2_LIBRARY_FILESYSTEM_V3_SUPPORT || {{Yes}}14.0 || {{No}}No || {{No}}No || Boost.FileSystem
 
|}
 
|}
  

Revision as of 03:07, 10 June 2015

KlayGE 4.2开始,一些C++11特性被引入代码中,部分替代了原先使用boost实现的功能。根据编译器和版本的不同,KFL会定义一些宏,来判断一个功能是否可用。这些宏都定义在KFL/Config.hpp中。

C++11核心语言功能

语言功能 MSVC GCC Clang 替代方案
Allowing move constructors to throw [noexcept] KLAYGE_CXX11_CORE_NOEXCEPT_SUPPORT 14.0 4.6 3.0 throw()
Declared type of an expression KLAYGE_CXX11_CORE_DECLTYPE_SUPPORT 10.0 4.3 3.0 Boost.Typeof
Extern templates KLAYGE_CXX11_CORE_EXTERN_TEMPLATES_SUPPORT 9.0 4.3 3.0
Explicit virtual overrides KLAYGE_CXX11_CORE_OVERRIDE_SUPPORT 11.0 4.7 3.0 #define
Generalized constant expressions KLAYGE_CXX11_CORE_CONSTEXPR_SUPPORT No 4.6 3.0
Null pointer constant KLAYGE_CXX11_CORE_NULLPTR_SUPPORT 10.0 4.6 3.0 自己实现的null_ptr
Range-based for KLAYGE_CXX11_CORE_FOREACH_SUPPORT 11.0 4.6 3.0 Boost.Foreach
Rvalue references KLAYGE_CXX11_CORE_RVALUE_REFERENCES_SUPPORT 11.0 4.3 3.0 Boost.Move
Static assertions KLAYGE_CXX11_CORE_STATIC_ASSERT_SUPPORT 10.0 4.3 3.0 Boost.StaticAssert
Strongly-typed enums KLAYGE_CXX11_CORE_STRONGLY_TYPED_ENUMS_SUPPORT 11.0 4.4 3.0 C++98的enum
Variadic templates KLAYGE_CXX11_CORE_VARIADIC_TEMPLATES 12.0 4.3 3.0

C++11核心语言功能:并行

C++11核心语言功能:C99

C++11库

名称 MSVC GCC Clang 替代方案
algorithm (只用了copy_if) KLAYGE_CXX11_LIBRARY_ALGORITHM_SUPPORT 11.0 4.3 3.0 Self-implemented copy_if
array KLAYGE_CXX11_LIBRARY_ARRAY_SUPPORT 10.0 4.3 3.0 Boost.Array
atomic KLAYGE_CXX11_LIBRARY_ATOMIC_SUPPORT 11.0 4.4 3.0 Boost.Atomic
chrono KLAYGE_CXX11_LIBRARY_CHRONO_SUPPORT 11.0 4.4 (必须有_GLIBCXX_HAS_GTHREADS) 3.0 Boost.Chrono
cstdint KLAYGE_CXX11_LIBRARY_CSTDINT_SUPPORT 10.0 4.3 3.0 Boost.Integer
functional KLAYGE_CXX11_LIBRARY_FUNCTIONAL_SUPPORT 10.0 4.3 3.0 Boost.Functional
mem_fn KLAYGE_CXX11_LIBRARY_MEM_FN_SUPPORT 12.0 No No Boost.MemFn
random KLAYGE_CXX11_LIBRARY_RANDOM_SUPPORT 10.0 4.3 3.0 Boost.Random
regex KLAYGE_CXX11_LIBRARY_REGEX_SUPPORT 10.0 4.9 3.0 Boost.Regex
smart_ptr KLAYGE_CXX11_LIBRARY_SMART_PTR_SUPPORT 11.0 4.3 3.0 Boost.SmartPtr
system_error KLAYGE_CXX11_LIBRARY_SYSTEM_ERROR_SUPPORT 10.0 4.4 3.0 Boost.System
thread KLAYGE_CXX11_LIBRARY_THREAD_SUPPORT 11.0 4.4 (必须有_GLIBCXX_HAS_GTHREADS) 3.0 Boost.Thread
tuple KLAYGE_CXX11_LIBRARY_TUPLE_SUPPORT 10.0 4.3 3.0 Boost.Tuple
type_traits KLAYGE_CXX11_LIBRARY_TYPE_TRAITS_SUPPORT 10.0 4.3 3.0 Boost.TypeTraits
unordered KLAYGE_CXX11_LIBRARY_UNORDERED_SUPPORT 10.0 4.3 3.0 Boost.Unordered

TR2

名称 MSVC GCC Clang 替代方案
filesystem KLAYGE_TR2_LIBRARY_FILESYSTEM_V2_SUPPORT 11.0 No No Boost.FileSystem
filesystem KLAYGE_TR2_LIBRARY_FILESYSTEM_V3_SUPPORT 14.0 No No Boost.FileSystem

相关内容

多种编译器对C++11的支持

使用到的boost库