Background: I am in a large code environment where the undefined order in which the global constructors are running is problematic. Therefore, I have a custom class that is designed to delay initialization until first use. All his magic happens inside her operators * and operator-> functions; they are the only thing defined. It also saves some state within itself to make the auto-initialization function available. Of course, this state must be POD, so that the entire POD class, so that it can be fully configured before any code starts working, so that all code can use all global variables everywhere, without fear, it is not yet configured .
While someone added a private, never-assigned assignment operator, so the type will never be assigned (it is not intended to be changed in any way). Now someone says the class is broken because it is not a POD. If instead of it is declared, but not defined, I declare it "= delete", I think it is somehow better. And indeed, with this change, the value of std :: is_pod <> :: returns true for the type.
But how does an assignment operator prevent a type from being a POD? I thought that the requirements are that it should have only public data elements, no virtual methods and no constructor or destructor.
And even more important for my situation: is the presence of an undefined class assignment operator from class initialization due to global initialization time together with all other global PODs?
Reduced example:
struct LazyString { const char *c_str; bool has_been_inited; string *lazy_str_do_not_use_directly; string &operator*() { return *get(); } string *operator->() { return get(); } private: string *get() {
source share