Specialized template function with deleted “general” case fails to compile with g++

I don’t know if the following will be enlightening but I found defect report 941: Explicit specialization of deleted function template with status C++11 that states the following (Emphasis Mine): According to 14.7.3 [temp.expl.spec] paragraph 1, only non-deleted function templates may be explicitly specialized. There doesn’t appear to be a compelling need for this restriction, … Read more

error: use of deleted function

The error message clearly says that the default constructor has been deleted implicitly. It even says why: the class contains a non-static, const variable, which would not be initialized by the default ctor. class X { const int x; }; Since X::x is const, it must be initialized — but a default ctor wouldn’t normally … Read more

How is “=default” different from “{}” for default constructor and destructor?

This is a completely different question when asking about constructors than destructors. If your destructor is virtual, then the difference is negligible, as Howard pointed out. However, if your destructor was non-virtual, it’s a completely different story. The same is true of constructors. Using = default syntax for special member functions (default constructor, copy/move constructors/assignment, … Read more