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

Detailed Description

Outline

Purpose

Provide a meta-function to transform pointer type to referent type.

Classes

See also
bslmf_addpointer

Description

This component defines a meta-function, bsl::remove_pointer, that may be used to obtain the type pointed to by a pointer type.

bsl::remove_pointer and bsl::remove_pointer_t meet the requirements of the remove_pointer template defined in the C++11 standard [meta.trans.ptr].

Usage

In this section we show intended use of this component.

Example 1: Get the Type Pointed to by a Pointer Type

Suppose that we want to get the type pointed to by a pointer type.

First, we create two typedefs – a pointer type (MyPtrType) and the type pointed to by the pointer type (MyType):

typedef int MyType;
typedef int *MyPtrType;

Now, we get the type pointed to by MyPtrType using bsl::remove_pointer and verify that the resulting type is the same as MyType:

MyType>::value));
Definition bslmf_issame.h:146
BloombergLP::bslmf::RemovePointer_Imp< t_TYPE >::Type type
Definition bslmf_removepointer.h:267

Finally, if the current compiler supports alias templates C++11 feature, we get the type pointed to by MyPtrType using bsl::remove_pointer_t and verify that the resulting type is the same as MyType:

#ifdef BSLS_COMPILERFEATURES_SUPPORT_ALIAS_TEMPLATES
assert((bsl::is_same<bsl::remove_pointer_t<MyPtrType>, MyType>::value));
#endif

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