According to this site /link/:
If the default constructor is explicitly declared but marked as deleted, empty brace initialization can't be used:
and it also gives an example to this:
class class_f {
public:
class_f() = delete;
class_f(string x): m_string { x } {} // if it is deleted, there will be no errors.
string m_string;
};
int main()
{
class_f cf{ "hello" };
class_f cf1{}; // compiler error C2280: attempting to reference a deleted function
}
What I don't really understand is that, if there is no user-provided constructor, there will be no more error, even if the deleted default constructor is still there. As far as I know, if there is a user-provided constructor, there will be no implicit default constructors, but the default constructor is already deleted. So I don't know what is called in case of the value-initialization and why it is works in the example below:
#include <string>
class class_f {
public:
class_f() = delete;
std::string m_string;
};
int main()
{
class_f cf1{}; // Does the implicit-default constructor is called here? But, it is deleted or not?
}