Quick Links: |
Provide a compile-time type transformation to lvalue reference. More...
bsl::add_lvalue_reference | standard meta-function for type transformation |
bsl::add_lvalue_reference_t | alias to the return type of the meta-function |
bsl::add_lvalue_reference
, that may be used to transform a type to its lvalue reference type. An lvalue, as defined in C++11 standard [basic.lval], is an expression that designates a function or an object. bsl::add_lvalue_reference
and bsl::add_lvalue_reference_t
meet the requirements of the add_lvalue_reference
template defined in the C++11 standard [meta.trans.ref]. bsl::add_lvalue_reference
template for each of these types, and use the bsl::is_same
meta-function to assert the type
static data member of each instantiation: assert(true == (bsl::is_same<bsl::add_lvalue_reference<int>::type, int&>::value)); assert(false == (bsl::is_same<bsl::add_lvalue_reference<int>::type, int >::value)); assert(true == (bsl::is_same<bsl::add_lvalue_reference<int&>::type, int&>::value)); #if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) assert(true == (bsl::is_same<bsl::add_lvalue_reference<int&&>::type, int&>::value)); #endif
bsl::add_lvalue_reference_t
template for the same set of types, and use the bsl::is_same
meta-function to assert the resultant type of each instantiation: #ifdef BSLS_COMPILERFEATURES_SUPPORT_ALIAS_TEMPLATES assert(true == (bsl::is_same<bsl::add_lvalue_reference_t<int>, int& >::value)); assert(false == (bsl::is_same<bsl::add_lvalue_reference_t<int>, int >::value)); assert(true == (bsl::is_same<bsl::add_lvalue_reference_t<int&>, int& >::value)); #if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) assert(true == (bsl::is_same<bsl::add_lvalue_reference_t<int&&>, int&&>::value)); #endif #endif
bsl::add_lvalue_reference_t
avoids the ::type
suffix and typename
prefix when we want to use the result of bsl::add_lvalue_reference
meta-function in templates.