Quick Links:

bal | bbl | bdl | bsl

Classes

Component bslmf_removecvref
[Package bslmf]

Provide a meta-func for removing reference-ness and cv-qualifiers. More...

Classes

struct  bsl::remove_cvref< t_TYPE >

Detailed Description

Outline
Purpose:
Provide a meta-func for removing reference-ness and cv-qualifiers.
Classes:
bsl::remove_cvref meta-func for removing reference-ness and cv-qualifiers
bsl::remove_cvref_t alias to the return type of the meta-function
See also:
Component bslmf_removecv, Component bslmf_removereference
Description:
This component defines a meta-function, bsl::remove_cvref, and declares a bsl::remove_cvref_t alias to the return type of the bsl::remove_cvref, that may be used to strip reference-ness (including both lvalue and rvalue reference-ness, if the latter is supported by the compiler) and to remove any top-level cv-qualifiers (const-qualifier and volatile-qualifier) from a type.
bsl::remove_cvref and bsl::remove_cvref_t meet the requirements of the remove_cvref template defined in the C++20 standard [meta.trans.other].
Usage:
In this section we show intended use of this component.
Example 1: Removing the CV-Qualifiers and Reference-ness of a Type:
Suppose that we want to remove the cv-qualifiers from a particular type.
First, we create two typedefs -- a const-qualified and volatile-qualified reference type (MyCvRefType) and the same type without the cv-qualifiers and reference-ness (MyType):
      typedef const volatile int& MyCvRefType;
      typedef                int  MyType;
Now, we remove the cv-qualifiers from MyCvRefType and its reference-ness using bsl::remove_cvref and verify that the resulting type is the same as MyType:
      assert(true == (bsl::is_same<bsl::remove_cvref<MyCvRefType>::type,
                                   MyType>::value));
Finally, if the current compiler supports alias templates C++11 feature, we remove a const-qualifier, volatile-qualifier and its reference-ness from MyCvRefType using bsl::remove_cvref_t and verify that the resulting type is the same as MyType:
#ifdef BSLS_COMPILERFEATURES_SUPPORT_ALIAS_TEMPLATES
      assert(
          true ==
          (bsl::is_same<bsl::remove_cvref_t<MyCvRefType>, MyType>::value));
#endif