I'm trying to check if a default constructor exists for a template argument. I want to do something like this:
template <typename A>
class Blah
{
Blah() { A* = new A(); }
}
But i want to detect at compile time via SFINAE or some other trick if that constructor exists, and raise a static_assert
of my own if it doesn't.
The problem arises when i have classes (like std::vector
) that dont have a "default constructor" but a constructor with default parameters.
So using std::has_trivial_default_constructor
won't return true. Although i can use new vector<T>()
.