BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bslmf_removecvref

Detailed Description

Outline

Purpose

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

Classes

See also
bslmf_removecv, 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:

MyType>::value));
Definition bslmf_issame.h:146
bsl::remove_cv< typenamebsl::remove_reference< t_TYPE >::type >::type type
Definition bslmf_removecvref.h:136

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