Quick Links:

bal | bbl | bdl | bsl

Classes

Component bslmf_removevolatile
[Package bslmf]

Provide a meta-function for removing volatile-qualifier. More...

Classes

struct  bsl::remove_volatile< t_TYPE >
struct  bsl::remove_volatile< t_TYPE volatile >

Detailed Description

Outline
Purpose:
Provide a meta-function for removing volatile-qualifier.
Classes:
bsl::remove_volatile meta-function for removing volatile-qualifier
bsl::remove_volatile_t alias to the return type of the meta-function
See also:
Component 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:
  assert(true == (bsl::is_same<bsl::remove_volatile<MyVolatileType>::type,
                                                            MyType>::value));
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.