| Home | Libraries | People | FAQ | More

### add_reference

| Note
This trait has been made obsolete by add_lvalue_reference and add_rvalue_reference, and new code should use these new traits rather than is_reference which is retained for backwards compatibility only.

    template <class T>
    struct add_reference
    {
       typedef see-below type;
    };

    template <class T> using add_reference_t = typename add_reference<T>::type; // C++11 and above

type: If `T` is not a reference type then `T&`, otherwise `T`.

C++ Standard Reference: 8.3.2.

Header: `#include <boost/type_traits/add_reference.hpp>` or `#include <boost/type_traits.hpp>`

Table 1.14. Examples

Expression | Result Type
--- | ---
`add_reference<int>::type` | `int&`
`add_reference<int const&>::type` | `int const&`
`add_reference<int*>::type` | `int*&`
`add_reference<int*&>::type` | `int*&`

Compiler Compatibility: All current compilers are supported by this trait.