Take the following code:
struct Foo {}
template<typename T>
void passFoo(T t) {}
I would want the domain of passFoo
to be restricted to Foo
objects, but I don't mind if they are references, pointers, or cv qualified. Is it possible to somehow remove all those aspects of a type to get down to the "plain" type, when using a concept? For instance:
template<typename T>
concept Foo_C = std::is_same_v<Foo, plainify<T>>;
template<Foo_C Foo_c>
void passFoo(Foo_c foo) {}
In that hypothetical code, passFoo
could accept only Foo
, Foo&
, Foo*
, const Foo
, etc. Is there any actual way to do this?
CodePudding user response:
Combination of std::remove_cvref_t
and std::remove_pointer_t
would work:
template<typename T>
concept Foo_C = std::is_same_v<Foo, std::remove_cvref_t<std::remove_pointer_t<T>>>;