Share via


add_reference Class

Makes reference to type from type.

template<class Ty>
    struct add_reference;

Parameters

  • Ty
    The type to modify.

Remarks

An instance of the type modifier holds a modified-type that is Ty if Ty is a reference, otherwise Ty&.

Example

 

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

Requirements

Header: <type_traits>

Namespace: std

See Also

Reference

<type_traits>

remove_reference Class