考虑这段代码:
#include <type_traits>
template <typename T>
struct wrapper {
T& ref;
constexpr wrapper(T& ref) : ref(ref) {}
};
// Trait that checks whether a type is of the form `wrapper<T>`
template <typename T>
struct is_wrapper_type : std::false_type {};
template <typename T>
struct is_wrapper_type<wrapper<T>> : std::true_type {};
// Trait that checks whether an object is of the type `wrapper<T>`
template <auto& Value>
struct is_wrapper_object;
template <auto& Value>
requires (!is_wrapper_type<std::decay_t<decltype(Value)>>::value)
struct is_wrapper_object<Value> : std::false_type {};
template <auto& Value>
requires is_wrapper_type<std::decay_t<decltype(Value)>>::value
struct is_wrapper_object<Value> …Run Code Online (Sandbox Code Playgroud) c++ language-lawyer compiler-bug c++20 non-type-template-parameter