|
BDE 4.14.0 Production release
|
Provide a meta-function for removing top-level const-qualifier.
const-qualifierbsl::remove_constThis component defines a meta-function, bsl::remove_const and declares an bsl::remove_const_t alias to the return type of the bsl::remove_const, that may be used to remove any top-level const-qualifier from a type.
bsl::remove_const and bsl::remove_const_t meet the requirements of the remove_const template defined in the C++11 standard [meta.trans.cv].
In this section we show intended use of this component.
Suppose that we want to remove any top-level const-qualifier from a particular type.
First, we create two typedefs – a const-qualified type (MyConstType) and the same type without the const-qualifier (MyType):
Now, we remove the const-qualifier from MyConstType using bsl::remove_const and verify that the resulting type is the same as MyType:
Finally, if the current compiler supports alias templates C++11 feature, we remove a const-qualifier from MyConstType using bsl::remove_const_t and verify that the resulting type is the same as MyType:
Note, that the bsl::remove_const_t avoids the ::type suffix and typename prefix when we want to use the result of the bsl::remove_const meta-function in templates.