Wiki¶
Contents¶
- C++0X library overview
- C++11 standard library features
- C++11 core language features
- Release Notes (Separate page)
C++0X
library overview¶
With the release of art 1.18.00, support for cpp0x
has been discontinued: its use is incompatible with ROOT 6.
cpp0x
library is to facilitate programmers' early adoption of the new C++11 standard, formerly known as C++0X. To do so, the library provides:
- Macros to stand in for selected new core language features,
- Headers to stand in for new or significantly enhanced C++11 headers, and
- Feature tests to identify which C++11 features are already natively supported by the environment.
Client code can make free use of the macros and the headers; they are coded so as to use the native implementation where/when one is available and (where possible) a workaround otherwise. The feature tests are principally an implementation detail; they are described here for those rare situations in which client code needs to adjust to situations where no workaround is provided.
The cpp0x
library does not (and likely will never) address every feature that is new to C++11. However, suggestions for useful library enhancements are welcome.
As prerequisites, the cpp0x
library assumes a reasonably recent gcc compiler, and a moderately recent boost library.
The following sections briefly list those C++11 features addressed by this cpp0x
library. Please consult other resources (e.g., Bjarne Stroustrup's C++0x - the next ISO C++ standard) for tutorial and reference materials regarding the design and use of these new C++ features.
C++11 standard library features (alphabetized by header)¶
<algorithm>
¶
"cpp0x/algorithm"
supports all of C++03<algorithm>
, plus the following C++11 additions:std::all_of
,std::any_of
,std::none_of
std::minmax_element
std::is_sorted
std::find_if_not
std::copy_n
,std::uninitialized_copy_n
std::shuffle
std::is_partitioned
,std::partition_point
- See C++11 Clause 25 for documentation of all C++11 algorithms, including those listed here.
<array>
¶
"cpp0x/array"
stands in for the new C++11<array>
header that contains the new, fixed-size containerstd::array
.- See C++11 Clause 23 for documentation of all C++11 containers, including
<array>
.
<cmath>
¶
"cpp0x/cmath"
supports all of C++03<cmath>
, plus the following C++11 additions:- Classification: std::fpclassify, std::isinf, std::isnan, std::isnormal
- Hyperbolic:
std::asinh
,std::acosh
,std::atanh
- Miscellaneous:
std::fmax
,std::fmin
,std::fdim
,std::fma
- Normalization:
std::scalbln
,std::scalbn
- Powers:
std::cbrt
,std::hypot
,std::exp2
,std::expm1
,std::ilogb
,std::log1p
,std::log2
,std::logb
- Remainder:
std::remainder
,std::remquo
- Rounding:
std::llrint
,std::llround
,std::lrint
,std::lround
,std::nearbyint
,std::rint
,std::round
,std::trunc
- Single-bit:
std::copysign
,std::nextafter
,std::nexttoward
,std::nan
- Special:
std::erf
,std::erfc
,std::lgamma
,std::tgamma
- See C++11 Clause 26 for documentation of all C++11 numerical functions and algorithms, including those listed here. Additional details are found in the C99 ISO standard, to which the C++11 standard refers.
<cstddef>
¶
"cpp0x/cstddef"
supports all of C++03<cstddef>
, plus the C++11 additionstd::nullptr_t
.- See C++11 Clause 18 for documentation of all C++11's language support headers, including the
<cstddef>
type listed here. See also the core languagenullptr
feature described below.
<cstdint>
¶
"cpp0x/cstdint"
stands in for the new C++11<cstdint>
header that provides aliases for four families of integer types:- Exact-size type aliases:
std::int8_t
,std::int16_t
,std::int32_t
,std::int64_t
,std::uint8_t
,std::uint16_t
,std::uint32_t
,std::uint64_t
- Minimum-size type aliases:
std::int_least8_t
,std::int_least16_t
,std::int_least32_t
,std::int_least64_t
,std::uint_least8_t
,std::uint_least16_t
,std::uint_least32_t
,std::uint_least64_t
- Performance type aliases:
std::int_fast8_t
,std::int_fast16_t
,std::int_fast32_t
,std::int_fast64_t
,std::uint_fast8_t
,std::uint_fast16_t
,std::uint_fast32_t
,std::uint_fast64_t
- Maximum-size type aliases:
std::intmax_t
,std::uintmax_t
- Exact-size type aliases:
- See C++11 Clause 18 for documentation of all C++11's language support headers, including the
<cstdint>
types listed here.
<functional>
¶
"cpp0x/functional"
supports all of C++03<functional>
, plus the following C++11 additions:std::bind
,std::is_bind_expression
,std::is_placeholder
std::placeholders::_1
,std::placeholders::_2
, etc.std::function
,std::bad_function_call
std::hash
std::mem_fn
std::ref
,std::cref
,std::reference_wrapper
- See C++11 Clause 20 for documentation of all C++11's general utility headers, including the
<functional>
facilities listed here.
<iterator>
¶
"cpp0x/iterator"
supports all of C++03<iterator>
, plus the C++11 additionsstd::begin
andstd::end
.- See C++11 Clause 24 for documentation of this C++11 iterator utilities header,
<iterator>
.
<memory>
¶
"cpp0x/memory"
supports all of C++03<memory>
, plus the following C++11 "smart pointer" additions:std::unique_ptr
,std::default_delete
std::shared_ptr
,std::weak_ptr
,std::bad_weak_ptr
,std::const_pointer_cast
,std::dynamic_pointer_cast
,std::enable_shared_from_this
,std::get_deleter
,std::make_shared
,std::static_pointer_cast
- See C++11 Clause 20 for documentation of all C++11's general utility headers, including the
<memory>
facilities listed here.
<numeric>
¶
"cpp0x/numeric"
supports all of C++03<numeric>
, plus the C++11 additionstd::iota
.- See C++11 Clause 26 for documentation of all C++11 numerical headers, including the
<numeric>
facility listed here.
<random>
¶
- "cpp0x/random" stands in for the new C++11
<random>
header that provides facilities to obtain random variates:- Sources of randomness ("random number engines"):
std::minstd_rand0
,std::minstd_rand
,std::mt19937
,std::mt19937_64
,std::ranlux24_base
,std::ranlux48_base
,std::ranlux24
,std::ranlux48
,std::knuth_b
,std::default_random_engine
- Sources of variates ("random number distributions"):
- Uniform distributions:
std::uniform_int_distribution
,std::uniform_real_distribution
- Bernoulli distributions:
std::bernoulli_distribution
,std::binomial_distribution
,std::geometric_distribution
,std::negative_binomial_distribution
- Poisson distributions:
std::poisson_distribution
,std::exponential_distribution
,std::gamma_distribution
,std::weibull_distribution
,std::extreme_value_distribution
- Normal distributions:
std::normal_distribution
,std::lognormal_distribution
,std::chi_squared_distribution
,std::cauchy_distribution
,std::fisher_f_distribution
,std::student_t_distribution
- Sampling distributions:
std::discrete_distribution
,std::piecewise_constant_distribution
,std::piecewise_linear_distribution
- Uniform distributions:
- Sources of randomness ("random number engines"):
- See C++11 Clause 26 for documentation of all C++11 numerical headers, including the
<random>
facilities listed here.
<regex>
¶
- "cpp0x/regex" stands in for the new C++11
<regex>
header that provides regular expression facilities:std::basic_regex
,std::regex
,std::wregex
std::regex_constants
std::regex_error
,std::regex_traits
std::swap
std::sub_match
,std::csub_match
,std::wcsub_match
,std::ssub_match
,std::wssub_match
std::match_results
,std::cmatch
,std::wcmatch
,std::smatch
,std::wsmatch
std::regex_match
std::regex_search
std::regex_replace
std::regex_iterator
,std::cregex_iterator
,std::wcregex_iterator
,std::sregex_iterator
,std::wsregex_iterator
std::regex_token_iterator
,std::cregex_token_iterator
,std::wcregex_token_iterator
,std::sregex_token_iterator
,std::wsregex_token_iterator
- See C++11 Clause 28 for documentation of this C++11 regular expression header,
<regex>
.
<string>
¶
"cpp0x/string"
supports all of C++03<string>
, plus the following C++11 additions- overload set
std::to_string
std::stoi
,std::stol
,std::stoul
,std::stoll
,std::stoull
,std::stof
,std::stod
,std::stold
- overload set
- See C++11 Clause 21 for documentation of all C++11 headers, including the
<string>
facilities listed here, that deal with manipulation of strings and null-terminated sequences.
<system_error>
¶
"cpp0x/system_error"
stands in for the new C++11<system_error>
header, providing system-level error manipulation:std::error_category
,std::error_code
,std::error_condition
,std::system_category
,std::system_error
,std::generic_category
std::make_error_code
,std::make_error_condition
std::is_error_code_enum
,std::is_error_condition_enum
- See C++11 Clause 19 for documentation of all C++11 diagnostics-related headers, including the
<system_error>
facilities listed here.
<tuple>
¶
"cpp0x/tuple"
stands in for the new C++11<tuple>
header, providing an extendedstd::pair
-like facility:std::tuple
std::ignore
,std::make_tuple
,std::tie
,std::get
std::tuple_size
,std::tuple_element
- See C++11 Clause 20 for documentation of all C++11's general utility headers, including the
<tuple>
facilities listed here.
<type_traits>
¶
"cpp0x/type_traits"
stands in for the new C++11<type_traits>
header, providing limited compile-time type introspection and manipulation:- helpers:
std::integral_constant
,std::true_type
,std::false_type
- primary type categories:
std::is_void
,std::is_integral
,std::is_floating_point
,std::is_array
,std::is_pointer
,std::is_lvalue_reference
,std::is_rvalue_reference
,std::is_member_object_pointer
,std::is_member_function_pointer
,std::is_enum
,std::is_union
,std::is_class
,std::is_function
- composite type categories:
std::is_reference
,std::is_arithmetic
,std::is_fundamental
,std::is_object
,std::is_scalar
,std::is_compound
,std::is_member_pointer
- type properties:
std::is_const
,std::is_volatile
,std::is_trivial
,std::is_trivially_copyable
,std::is_standard_layout
,std::is_pod
,std::is_literal_type
,std::is_empty
,std::is_polymorphic
,std::is_abstract
,std::has_default_constructor
,std::has_copy_constructor
,std::has_copy_assign
,std::has_move_constructor
,std::has_move_assign
,std::has_trivial_default_constructor
,std::has_trivial_copy_constructor
,std::has_trivial_move_constructor
,std::has_trivial_copy_assign
,std::has_trivial_move_assign
,std::has_trivial_destructor
,std::has_nothrow_default_constructor
,std::has_nothrow_copy_constructor
,std::has_nothrow_move_constructor
,std::has_nothrow_copy_assign
,std::has_nothrow_move_assign
,std::has_virtual_destructor
,std::is_signed
,std::is_unsigned
,std::alignment_of
,std::rank
,std::extent
- type relations:
std::is_same
,std::is_base_of
,std::is_convertible
- const-volatile modifications:
std::remove_const
,std::remove_volatile
,std::remove_cv
,std::add_const
,std::add_volatile
,std::add_cv
- reference modifications:
std::remove_reference
,std::add_lvalue_reference
,std::add_rvalue_reference
- sign modifications:
std::make_signed
,std::make_unsigned
- array modifications:
std::remove_extent
,std::remove_all_extents
- pointer modifications:
std::remove_pointer
,std::add_pointer
- other transformations:
std::aligned_storage
,std::decay
,std::enable_if
,std::conditional
,std::common_type
,std::result_of
- helpers:
- See C++11 Clause 20 for documentation of all C++11's general utility headers, including the
<type_traits>
facilities listed here.
<utility>
¶
"cpp0x/utility"
supports all of C++03<utility>
, plus the C++11 additionstd::declval
.- See C++11 Clause 20 for documentation of all C++11's general utility headers, including the
<utility>
facility listed here.
C++11 core language features (alphabetized by C++11 nomenclature)¶
auto
¶
- This keyword has been repurposed in C++11 and now is used to declare a variable's type to be consistent with the type of its initializer.
- This feature requires compiler support; no workaround is known.
- Use the symbol
CPP0X_HAS_AUTO
to detect this feature's availability.
constexpr
¶
- This new C++11 keyword is used:
- To require a variable to be initialized at compile-time, or
- To require a function to be called at compile-time whenever its arguments' values are known at compile-time.
- Use symbol
CONSTEXPR_VAR
when declaring such a variable; use symbolCONSTEXPR_FCTN
when declaring such a function. - These symbols use the compiler's implementation if the corresponding
constexpr
is supported; otherwise they cause variables to be treated asconst
and functions to be called at run-time only.
decltype
¶
- This new C++11 keyword is used to determine, at compile time, the type of a variable or of an expression.
- This feature requires compiler support; all known workarounds are intrusive, incomplete, or have other undesirable characteristics.
- Use the symbol
CPP0X_HAS_DECLTYPE
to detect this feature's availability.
explicit
conversion operators¶
- This keyword, previously used solely to restrict the applicability of conversion constructors (constructors callable with a single argument of a different type), is in C++11 additionally applicable to conversion operators.
- Use symbol
EXPLICIT_CONV_OP
when declaring such a restricted operator. - This symbol employs the native implementation if one is available; otherwise it has no effect.
lambda expressions¶
- C++11 has introduced the notion of a lambda expression which, upon evaluation, produces a closure object (a callable entity).
- This feature requires compiler support; all known workarounds use significantly different syntax or have other undesirable characteristics.
- Use the symbol
CPP0X_HAS_LAMBDAS
to detect this feature's availability.
noexcept
¶
- This new C++11 keyword is used when declaring a function that allows no exception to escape it.
- Use the new keyword as designed.
- Employs the native implementation if one is available; otherwise employs the empty throw-specification (
throw()
).
nullptr
¶
- This new C++11 keyword is used as a null pointer value; its type is
std::nullptr_t
. (See also the library header<cstddef>
described above.) - Use the new keyword as designed.
- Employs the native implementation if one is available; otherwise uses an alternate implementation.
parameter packs — see "variadic template parameters" below¶
rvalue references¶
- C++11 supports two kinds of reference types:
- The classic reference type, of the form
T &
, is now termed an lvalue reference - An additional reference type, of the form
T &&
, is now known as an rvalue reference
- The classic reference type, of the form
- This feature requires compiler support; no workaround is known.
- Use the symbol
CPP0X_HAS_RVALUE_REFERENCES
to detect this feature's availability.
static_assert
¶
- This new C++11 keyword requires the compiler to evaluate a given boolean expression and, if the result is
false
, to issue a specified diagnostic. - Use the new keyword as designed.
- Employs the native implementation if one is available; otherwise uses an alternate implementation.
template parameter defaults permitted in function templates¶
- C++03 did not permit function templates to declare default arguments for their template parameters; C++11 has removed this restriction.
- This feature requires compiler support; no workaround is known.
- Use the symbol
CPP0X_HAS_FCTN_TEMPLATE_DEFAULT_ARGS
to detect this feature's availability.
variadic template parameters (also termed parameter packs)¶
- C++11 introduces the notion of a template with an arbitrary number of template arguments.
- This feature requires compiler support; no workaround is known.
- Use the symbol
CPP0X_HAS_VARIADIC_TEMPLATES
to detect this feature's availability.