Provide meta-function to transform a type to pointer to that type.
More...
Namespaces |
namespace | bslmf |
namespace | bsl |
Detailed Description
- Outline
-
-
- Purpose:
- Provide meta-function to transform a type to pointer to that type.
-
- Classes:
-
- See also:
- Component bslmf_removepointer
-
- Description:
- This component defines a meta-function,
bsl::add_pointer
, that may be used to transform a type to a pointer to that type.
bsl::add_pointer
meets the requirements of the add_pointer
template defined in the C++11 standard [meta.trans.ptr].
-
- Usage:
- In this section we show intended use of this component.
-
- Example 1: Transform Type to Pointer Type to that Type:
- Suppose that we want to transform a type to a pointer type to that type.
- First, we create two
typedef
s -- a pointer type (MyPtrType
) and the type pointed to by the pointer type (MyType
): typedef int MyType;
typedef int * MyPtrType;
Now, we transform MyType
to a pointer type using bsl::add_pointer
and verify that the resulting type is the same as MyPtrType
: Finally, if the current compiler supports alias templates C++11 feature, we transform MyType
to a pointer type using bsl::add_pointer_t
and verify that the resulting type is the same as MyPtrType
: #ifdef BSLS_COMPILERFEATURES_SUPPORT_ALIAS_TEMPLATES
assert((bsl::is_same<bsl::add_pointer_t<MyType>, MyPtrType>::value));
#endif
Note, that the bsl::add_pointer_t
avoids the ::type
suffix and typename
prefix when we want to use the result of the bsl::add_pointer
meta-function in templates.