Edit

Share via


add_lvalue_reference Class

Makes reference to type from type.

Syntax

template <class T>
struct add_lvalue_reference;

template <class T>
using add_lvalue_reference_t = typename add_lvalue_reference<T>::type;

Parameters

T
The type to modify.

Remarks

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

Example

#include <type_traits>
#include <iostream>

using namespace std;
int main()
{
    int val = 0;
    add_lvalue_reference_t<int> p = (int&)val;
    p = p;  // to quiet "unused" warning
    cout << "add_lvalue_reference_t<int> == "
        << typeid(p).name() << endl;

    return (0);
}
add_lvalue_reference_t<int> == int

Requirements

Header: <type_traits>

Namespace: std

See also

<type_traits>
remove_reference Class