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

Detailed Description

Outline

Purpose

Provide a meta-function for removing volatile-qualifier.

Classes

See also
bslmf_addvolatile

Description

This component defines a meta-function, bsl::remove_volatile and declares an bsl::remove_volatile_t alias to the return type of the bsl::remove_volatile, that may be used to remove any top-level volatile-qualifier from a type.

bsl::remove_volatile and bsl::remove_volatile_t meet the requirements of the remove_volatile 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 volatile-Qualifier of a Type

Suppose that we want to remove any volatile-qualifier from a particular type.

First, we create two typedefs – a volatile-qualified type (MyVolatileType) and the same type without the volatile-qualifier (MyType):

typedef int MyType;
typedef volatile int MyVolatileType;

Now, we remove the volatile-qualifier from MyVolatileType using bsl::remove_volatile and verify that the resulting type is the same as MyType:

MyType>::value));
Definition bslmf_issame.h:146
t_TYPE type
This typedef is an alias to the (template parameter) t_TYPE.
Definition bslmf_removevolatile.h:163

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

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