In this SO question is stated that this construct prevents stack allocation of instance.
class FS_Only {
~FS_Only() = delete; // disallow stack allocation
};
My question is, how does it prevents allocation? I understand, that is not possible to delete this instance, either explicitly or implicitly. But I think, that would lead to memory leak or run time error, respectively.
Are compilers smart enough to sort this out and raise compiler error? Also why would one need this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…