Difference between revisions of "Used C++11 features"
From KlayGE
Gongminmin (Talk | contribs) m |
Gongminmin (Talk | contribs) |
||
Line 1: | Line 1: | ||
− | Starting from [[KlayGE]] 4.2, some C++11 features are introduced. | + | Starting from [[KlayGE]] 4.2, some C++11 features are introduced to replace some [[Used boost libraries|features from Boost]]. [[KFL]] defines some macros based on compiler names and versions, to ensure which features are useable. Those macros are defined in KFL/Config.hpp. |
== C++11 Core Language Features == | == C++11 Core Language Features == | ||
− | + | ||
− | + | {| class="wikitable" | |
− | + | |- | |
− | + | ! Language Feature !! Macro !! MSVC !! GCC !! Alternative | |
− | + | |- | |
− | + | | Static assertions || KLAYGE_CXX11_CORE_STATIC_ASSERT_SUPPORT || '''10.0''' || '''4.3''' || Boost.StaticAssert | |
+ | |- | ||
+ | | Declared type of an expression || KLAYGE_CXX11_CORE_DECLTYPE_SUPPORT || '''10.0''' || '''4.3''' || Boost.Typeof | ||
+ | |- | ||
+ | | Rvalue references || KLAYGE_CXX11_CORE_RVALUE_REFERENCES_SUPPORT || '''11.0''' || '''4.3''' || Boost.Move | ||
+ | |- | ||
+ | | Extern templates || KLAYGE_CXX11_CORE_EXTERN_TEMPLATES_SUPPORT || '''9.0''' || '''4.3''' || | ||
+ | |- | ||
+ | | Variadic templates || KLAYGE_CXX11_CORE_VARIADIC_TEMPLATES || '''12.0''' || '''4.3''' || | ||
+ | |- | ||
+ | | Strongly-typed enums || KLAYGE_CXX11_CORE_STRONGLY_TYPED_ENUMS_SUPPORT || '''11.0''' || '''4.4''' || C++98 enum | ||
+ | |- | ||
+ | | Null pointer constant || KLAYGE_CXX11_CORE_NULLPTR_SUPPORT || '''10.0''' || '''4.6''' || Self-implemented null_ptr | ||
+ | |- | ||
+ | | Range-based for || KLAYGE_CXX11_CORE_FOREACH_SUPPORT || '''11.0''' || '''4.6''' || Boost.Foreach | ||
+ | |- | ||
+ | | Allowing move constructors to throw [noexcept] || KLAYGE_CXX11_CORE_NOEXCEPT_SUPPORT || No || '''4.6''' || | ||
+ | |- | ||
+ | | Generalized constant expressions || KLAYGE_CXX11_CORE_CONSTEXPR_SUPPORT || No || '''4.6''' || | ||
+ | |- | ||
+ | | Explicit virtual overrides || KLAYGE_CXX11_CORE_OVERRIDE_SUPPORT || '''11.0''' || '''4.7''' || #define | ||
+ | |} | ||
== C++11 Core Language Features: Concurrency == | == C++11 Core Language Features: Concurrency == | ||
== C++11 Core Language Features: C99 == | == C++11 Core Language Features: C99 == | ||
− | |||
== C++11 Libraries == | == C++11 Libraries == | ||
− | + | ||
− | + | {| class="wikitable" | |
− | + | |- | |
− | + | ! Name !! Macro !! MSVC !! GCC !! Alternative | |
− | + | |- | |
− | + | | algorithm(only copy_if) || KLAYGE_CXX11_LIBRARY_ALGORITHM_SUPPORT || '''11.0''' || '''4.3''' || Self-implemented copy_if | |
− | + | |- | |
− | + | | array || KLAYGE_CXX11_LIBRARY_ARRAY_SUPPORT || '''10.0''' || '''4.3''' || Boost.Array | |
− | + | |- | |
− | + | | cstdint || KLAYGE_CXX11_LIBRARY_CSTDINT_SUPPORT || '''10.0''' || '''4.3''' || Boost.Integer | |
− | + | |- | |
+ | | functional || KLAYGE_CXX11_LIBRARY_FUNCTIONAL_SUPPORT || '''10.0''' || '''4.3''' || Boost.Functional | ||
+ | |- | ||
+ | | mem_fn || KLAYGE_CXX11_LIBRARY_MEM_FN_SUPPORT || '''12.0''' || No || Boost.MemFn | ||
+ | |- | ||
+ | | random || KLAYGE_CXX11_LIBRARY_RANDOM_SUPPORT || '''10.0''' || '''4.3''' || Boost.Random | ||
+ | |- | ||
+ | | regex || KLAYGE_CXX11_LIBRARY_REGEX_SUPPORT || '''10.0''' || '''4.3''' || Boost.Regex | ||
+ | |- | ||
+ | | smart_ptr || KLAYGE_CXX11_LIBRARY_SMART_PTR_SUPPORT || '''11.0''' || '''4.3''' || Boost.SmartPtr | ||
+ | |- | ||
+ | | tuple || KLAYGE_CXX11_LIBRARY_TUPLE_SUPPORT || '''10.0''' || '''4.3''' || Boost.Tuple | ||
+ | |- | ||
+ | | type_traits || KLAYGE_CXX11_LIBRARY_TYPE_TRAITS_SUPPORT || '''10.0''' || '''4.3''' || Boost.TypeTraits | ||
+ | |- | ||
+ | | unordered || KLAYGE_CXX11_LIBRARY_UNORDERED_SUPPORT || '''10.0''' || '''4.3''' || Boost.Unordered | ||
+ | |- | ||
+ | | atomic || KLAYGE_CXX11_LIBRARY_ATOMIC_SUPPORT || '''11.0''' || '''4.4''' || Boost.Atomic | ||
+ | |- | ||
+ | | system || KLAYGE_CXX11_LIBRARY_SYSTEM_ERROR_SUPPORT || '''10.0''' || '''4.4''' || Boost.System | ||
+ | |- | ||
+ | | chrono || KLAYGE_CXX11_LIBRARY_CHRONO_SUPPORT || '''11.0''' || '''4.4'''(Must have _GLIBCXX_HAS_GTHREADS) || Boost.Chrono | ||
+ | |- | ||
+ | | thread || KLAYGE_CXX11_LIBRARY_THREAD_SUPPORT || '''11.0''' || '''4.4'''(Must have _GLIBCXX_HAS_GTHREADS) || Boost.Thread | ||
+ | |} | ||
+ | |||
+ | == TR2 == | ||
+ | {| class="wikitable" | ||
+ | |- | ||
+ | ! Name !! Macro !! MSVC !! GCC !! Alternative | ||
+ | |- | ||
+ | | filesystem || KLAYGE_TR2_LIBRARY_FILESYSTEM_V2_SUPPORT || '''11.0''' || No || Boost.FileSystem | ||
+ | |} | ||
== See Also == | == See Also == |
Revision as of 03:11, 24 April 2014
Starting from KlayGE 4.2, some C++11 features are introduced to replace some features from Boost. KFL defines some macros based on compiler names and versions, to ensure which features are useable. Those macros are defined in KFL/Config.hpp.
Contents
C++11 Core Language Features
Language Feature | Macro | MSVC | GCC | Alternative |
---|---|---|---|---|
Static assertions | KLAYGE_CXX11_CORE_STATIC_ASSERT_SUPPORT | 10.0 | 4.3 | Boost.StaticAssert |
Declared type of an expression | KLAYGE_CXX11_CORE_DECLTYPE_SUPPORT | 10.0 | 4.3 | Boost.Typeof |
Rvalue references | KLAYGE_CXX11_CORE_RVALUE_REFERENCES_SUPPORT | 11.0 | 4.3 | Boost.Move |
Extern templates | KLAYGE_CXX11_CORE_EXTERN_TEMPLATES_SUPPORT | 9.0 | 4.3 | |
Variadic templates | KLAYGE_CXX11_CORE_VARIADIC_TEMPLATES | 12.0 | 4.3 | |
Strongly-typed enums | KLAYGE_CXX11_CORE_STRONGLY_TYPED_ENUMS_SUPPORT | 11.0 | 4.4 | C++98 enum |
Null pointer constant | KLAYGE_CXX11_CORE_NULLPTR_SUPPORT | 10.0 | 4.6 | Self-implemented null_ptr |
Range-based for | KLAYGE_CXX11_CORE_FOREACH_SUPPORT | 11.0 | 4.6 | Boost.Foreach |
Allowing move constructors to throw [noexcept] | KLAYGE_CXX11_CORE_NOEXCEPT_SUPPORT | No | 4.6 | |
Generalized constant expressions | KLAYGE_CXX11_CORE_CONSTEXPR_SUPPORT | No | 4.6 | |
Explicit virtual overrides | KLAYGE_CXX11_CORE_OVERRIDE_SUPPORT | 11.0 | 4.7 | #define |
C++11 Core Language Features: Concurrency
C++11 Core Language Features: C99
C++11 Libraries
Name | Macro | MSVC | GCC | Alternative |
---|---|---|---|---|
algorithm(only copy_if) | KLAYGE_CXX11_LIBRARY_ALGORITHM_SUPPORT | 11.0 | 4.3 | Self-implemented copy_if |
array | KLAYGE_CXX11_LIBRARY_ARRAY_SUPPORT | 10.0 | 4.3 | Boost.Array |
cstdint | KLAYGE_CXX11_LIBRARY_CSTDINT_SUPPORT | 10.0 | 4.3 | Boost.Integer |
functional | KLAYGE_CXX11_LIBRARY_FUNCTIONAL_SUPPORT | 10.0 | 4.3 | Boost.Functional |
mem_fn | KLAYGE_CXX11_LIBRARY_MEM_FN_SUPPORT | 12.0 | No | Boost.MemFn |
random | KLAYGE_CXX11_LIBRARY_RANDOM_SUPPORT | 10.0 | 4.3 | Boost.Random |
regex | KLAYGE_CXX11_LIBRARY_REGEX_SUPPORT | 10.0 | 4.3 | Boost.Regex |
smart_ptr | KLAYGE_CXX11_LIBRARY_SMART_PTR_SUPPORT | 11.0 | 4.3 | Boost.SmartPtr |
tuple | KLAYGE_CXX11_LIBRARY_TUPLE_SUPPORT | 10.0 | 4.3 | Boost.Tuple |
type_traits | KLAYGE_CXX11_LIBRARY_TYPE_TRAITS_SUPPORT | 10.0 | 4.3 | Boost.TypeTraits |
unordered | KLAYGE_CXX11_LIBRARY_UNORDERED_SUPPORT | 10.0 | 4.3 | Boost.Unordered |
atomic | KLAYGE_CXX11_LIBRARY_ATOMIC_SUPPORT | 11.0 | 4.4 | Boost.Atomic |
system | KLAYGE_CXX11_LIBRARY_SYSTEM_ERROR_SUPPORT | 10.0 | 4.4 | Boost.System |
chrono | KLAYGE_CXX11_LIBRARY_CHRONO_SUPPORT | 11.0 | 4.4(Must have _GLIBCXX_HAS_GTHREADS) | Boost.Chrono |
thread | KLAYGE_CXX11_LIBRARY_THREAD_SUPPORT | 11.0 | 4.4(Must have _GLIBCXX_HAS_GTHREADS) | Boost.Thread |
TR2
Name | Macro | MSVC | GCC | Alternative |
---|---|---|---|---|
filesystem | KLAYGE_TR2_LIBRARY_FILESYSTEM_V2_SUPPORT | 11.0 | No | Boost.FileSystem |