std::remove_cvref (3) - Linux Manuals
std::remove_cvref: std::remove_cvref
Command to display std::remove_cvref
manual in Linux: $ man 3 std::remove_cvref
NAME
std::remove_cvref - std::remove_cvref
Synopsis
Defined in header <type_traits>
template< class T > (since C++20)
struct remove_cvref;
If the type T is a reference type, provides the member typedef type which is the type referred to by T with its topmost cv-qualifiers removed. Otherwise type is T with its topmost cv-qualifiers removed.
Member types
Name Definition
type the type referred by T or T itself if it is not a reference, with top-level cv-qualifiers removed
Helper types
template< class T > (since C++20)
using remove_cvref_t = typename remove_cvref<T>::type;
Possible implementation
template< class T >
struct remove_cvref {
typedef std::remove_cv_t<std::remove_reference_t<T>> type;
};
Example
// Run this code
#include <iostream>
#include <type_traits>
int main()
{
std::cout << std::boolalpha
<< std::is_same_v<std::remove_cvref_t<int>, int> << '\n'
<< std::is_same_v<std::remove_cvref_t<int&>, int> << '\n'
<< std::is_same_v<std::remove_cvref_t<int&&>, int> << '\n'
<< std::is_same_v<std::remove_cvref_t<const int&>, int> << '\n'
<< std::is_same_v<std::remove_cvref_t<const int[2]>, int[2]> << '\n'
<< std::is_same_v<std::remove_cvref_t<const int(&)[2]>, int[2]> << '\n'
<< std::is_same_v<std::remove_cvref_t<int(int)>, int(int)> << '\n';
}
Output:
true
true
true
true
true
true
true
See also
remove_cv
remove_const
remove_volatile removes const or/and volatile specifiers from the given type
(class template)
(C++11)
(C++11)
(C++11)
remove_reference removes a reference from the given type
(class template)
(C++11)
decay applies type transformations as when passing a function argument by value
(class template)
(C++11)
Pages related to std::remove_cvref
- 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_const (3)
- std::remove_copy,std::remove_copy_if (3) - std::remove_copy,std::remove_copy_if
- std::remove_all_extents (3) - std::remove_all_extents
- std::remove_extent (3) - std::remove_extent
- std::remove_pointer (3) - std::remove_pointer
- std::remove_reference (3) - std::remove_reference
- 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