Udostępnij za pośrednictwem


add_pointer Class

Makes a pointer-to-type from a specified type.

template<class Ty>
    struct add_pointer;

Parameters

  • Ty
    The type to modify.

Remarks

The member typedef type names the same type as remove_reference<T>::type*.

Because it is invalid to make a pointer from a reference, add_pointer removes the reference, if any, from the specified type before it makes a pointer-to-type. Consequently, you can use a type with add_pointer without being concerned about whether the type is a reference.

Example

The following example demonstrates that add_pointer of a type is the same as a pointer to that type.

// std_tr1__type_traits__add_pointer.cpp 
// compile with: /EHsc 
#include <type_traits> 
#include <iostream> 
 
int main() 
    { 
    std::add_pointer<int>::type *p = (int **)0; 
 
    p = p;  // to quiet "unused" warning 
    std::cout << "add_pointer<int> == " 
        << typeid(*p).name() << std::endl; 
 
    return (0); 
    } 
 
add_pointer<int> == int *

Requirements

Header: <type_traits>

Namespace: std

See Also

Reference

<type_traits>

remove_pointer Class

Other Resources

<type_traits> Members