BDE 4.14.0 Production release
|
Provide a compile-time type transformation to lvalue reference.
This component defines a 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].
In this section we show intended use of this component.
Suppose that we want to transform a set of types to their lvalue reference types.
Now, we instantiate the 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:
Finally, if the current compiler supports alias templates C++11 feature, we instantiate the 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:
Note, that the rvalue reference used above is a feature introduced in the C++11 standard and may not be supported by all compilers.
Also note that the 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.