std::remove_reference (3) - Linux Manuals
std::remove_reference: std::remove_reference
Command to display std::remove_reference
manual in Linux: $ man 3 std::remove_reference
NAME
std::remove_reference - std::remove_reference
Synopsis
Defined in header <type_traits>
template< class T > (since C++11)
struct remove_reference;
If the type T is a reference type, provides the member typedef type which is the type referred to by T. Otherwise type is T.
Member types
Name Definition
type the type referred by T or T if it is not a reference
Helper types
template< class T > (since C++14)
using remove_reference_t = typename remove_reference<T>::type;
Possible implementation
template< class T > struct remove_reference {typedef T type;};
template< class T > struct remove_reference<T&> {typedef T type;};
template< class T > struct remove_reference<T&&> {typedef T type;};
Example
// Run this code
#include <iostream> // std::cout
#include <type_traits> // std::is_same
template<class T1, class T2>
void print_is_same() {
std::cout << std::is_same<T1, T2>() << '\n';
}
int main() {
std::cout << std::boolalpha;
print_is_same<int, int>();
print_is_same<int, int &>();
print_is_same<int, int &&>();
print_is_same<int, std::remove_reference<int>::type>();
print_is_same<int, std::remove_reference<int &>::type>();
print_is_same<int, std::remove_reference<int &&>::type>();
}
Output:
true
false
false
true
true
true
See also
is_reference checks if a type is either a lvalue reference or rvalue reference
(class template)
(C++11)
add_lvalue_reference
add_rvalue_reference adds a lvalue or rvalue reference to the given type
(class template)
(C++11)
(C++11)
remove_cvref combines std::remove_cv and std::remove_reference
(class template)
(C++20)
Pages related to std::remove_reference
- std::remove_all_extents (3) - std::remove_all_extents
- std::remove_const (3)
- std::remove_copy,std::remove_copy_if (3) - std::remove_copy,std::remove_copy_if
- std::remove_cv,std::remove_const,std::remove_volatile (3) - std::remove_cv,std::remove_const,std::remove_volatile
- std::remove_cv (3)
- std::remove_cvref (3) - std::remove_cvref
- std::remove_extent (3) - std::remove_extent
- std::remove_pointer (3) - std::remove_pointer
- std::remove_volatile (3)
- std::remove,std::remove_if (3) - std::remove,std::remove_if
- std::remove (3) - std::remove
- std::remainder,std::remainderf,std::remainderl (3) - std::remainder,std::remainderf,std::remainderl