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

Detailed Description

Outline

Purpose

Provide a meta-function for removing top-level cv-qualifiers.

Classes

See also
bslmf_addcv

Description

This component defines a meta-function, bsl::remove_cv, and declares a bsl::remove_cv_t alias to the return type of the bsl::remove_cv, that may be used to remove any top-level cv-qualifiers (const-qualifier and volatile-qualifier) from a type.

bsl::remove_cv and bsl::remove_cv_t meet the requirements of the remove_cv template defined in the C++11 standard [meta.trans.cv].

Usage

In this section we show intended use of this component.

Example 1: Removing the CV-Qualifiers 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 type (MyCvType) and the same type without the cv-qualifiers (MyType):

typedef int MyType;
typedef const volatile int MyCvType;

Now, we remove the cv-qualifiers from MyCvType using bsl::remove_cv and verify that the resulting type is the same as MyType:

MyType>::value));
Definition bslmf_issame.h:146
remove_const< typenameremove_volatile< t_TYPE >::type >::type type
Definition bslmf_removecv.h:126

Finally, if the current compiler supports alias templates C++11 feature, we remove a const-qualified and volatile-qualifier from MyCvType using bsl::remove_cv_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_cv_t<MyCvType>, MyType>::value));
#endif

Note, that the bsl::remove_cv_t avoids the ::type suffix and typename prefix when we want to use the result of the bsl::remove_cv meta-function in templates.