Given a class template like this:
template<typename T>
struct foo
{
T data;
};
How may one determine whether T is a smart pointer such as std::shared_ptr<T_underlying> using C++20 concepts?
I want to add functionality to foo<T> based on this criteria. For example, Instead of using SFINAE, I'd like to use the new concept system.
I want to achieve something like this:
template<typename T>
struct foo
{
T data;
void func()
requires is_shared_ptr_v<T>
{
// ...
}
};
Are there existing concepts for this in the STL? If not, I assume I can write a concept for std::shared_ptr, one for std::unique_ptr and so on and then tie them together with logical or in a general is_smart_pointer concept?
T*andoptional<T>?is_shared_ptr_vtrait, which you would do in the same way it's been done since c++11.Tare relevant for you? Get that nailed down, then test for it as much as feasible, and finally convert to aconcept.