Do invocations of std constructors need to be qualified with std::?
class whatever : public std::runtime_error
{
public:
explicit whatever(const std::string& what) : runtime_error(what) {}
}; // ^ do I need std:: here?
It works on my compiler without the qualification, but I’m not sure whether that behavior is standard.
No you don’t. The names in the initializer list are looked up in the scope of the
whateverclass. This class scope includes names declared in base classes and the name of the base class (runtime_error) is inserted into the scope ofstd::runtime_error(this is standard behaviour for all classes).Note that this doesn’t work if the name that you use is a
typedeffor the actual class name. You can easily be tempted with, e.g.,std::istreamand friends. See here.