|
BDE 4.14.0 Production release
|
Provide meta-function to transform a type to pointer to that type.
bsl::add_pointerThis 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].
In this section we show intended use of this component.
Suppose that we want to transform a type to a pointer type to that type.
First, we create two typedefs – a pointer type (MyPtrType) and the type pointed to by the pointer type (MyType):
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:
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.