std::remove_cvref(3)
β¨ std::remove_cvref(3) β¨
okay bestie, welcome to the C++ Standard Libary manual page for std::remove_cvref β yes, that's the manual name, and it's giving "type-trait bestie who removes a reference and then clears the cv-qualifiers" energy π
. This page is literally std::remove_cvref(3), and we're about to get your types together.
π 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, this 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. β¨
π¨ If the program adds specializations for std::remove_cvref, the behavior is undefined. Like, do not customize this one, bestie β that's not the vibe, fr fr.
π Member types π
Name β Definition:
typeβ the type referred byTorTitself if it is not a reference, with top-level cv-qualifiers removed.
π¦ Helper types π¦
template< class T > (since C++20)
using remove_cvref_t = remove_cvref<T>::type;
π Possible implementation π
template<class T>
struct remove_cvref
{
using type = std::remove_cv_t<std::remove_reference_t<T>>;
};
π₯ Notes π₯
Feature-test macro table, but make it cute:
- Feature-test macro:
__cpp_lib_remove_cvref - Value:
201711L - Std:
(C++20) - Feature:
std::remove_cvref
π Example π
// Run this code
#include <type_traits>
int main()
{
static_assert(std::is_same_v<std::remove_cvref_t<int>, int>);
static_assert(std::is_same_v<std::remove_cvref_t<int&>, int>);
static_assert(std::is_same_v<std::remove_cvref_t<int&&>, int>);
static_assert(std::is_same_v<std::remove_cvref_t<const int&>, int>);
static_assert(std::is_same_v<std::remove_cvref_t<const int[2]>, int[2]>);
static_assert(std::is_same_v<std::remove_cvref_t<const int(&)[2]>, int[2]>);
static_assert(std::is_same_v<std::remove_cvref_t<int(int)>, int(int)>);
}
π See also π
remove_cvβ(C++11), class template.remove_constβ(C++11), class template.remove_volatileβ removes const and/or volatile specifiers from the given type;(C++11), class template.remove_referenceβ removes a reference from the given type;(C++11), class template.decayβ applies type transformations as when passing a function argument by value;(C++11), class template.
cute sign-off: this page is from http://cppreference.com, version/date 2024.06.10, and it's literally std::remove_cvref(3) β slay, go remove those qualifiers, bestie ππ«Ά
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms