Quick Q: Delete its constructor
Recently on SO:
Make C++ fail compilation on specific instantiation of template function
Since foo is a complete specialization, it will always get compiled, and the static assert will always get called.
However, there’s an easier way:
template <> Bar foo<Bar>(Bar val) = delete;This will say that this specific version is deleted, and cannot be called.
Add a Comment
Comments are closed.