I've been playing around and got curious with this following code.
struct Bar {
Bar()=delete;
~Bar() { std::cout << "dtor" << std::endl; }
};
struct Foo {
Foo(){}
~Foo() { std::cout << "dtor" << std::endl; }
};
Bar b(); // (A) doesn't call dtor
Foo f(); // (B) doesn't call dtor
Foo f; // (C) calls dtor
Bar b; // (D) error: use of deleted function 'Bar::Bar()'
QUESTIONS
- Why the destructor is not called for both (A) and (B)?
- Is there some magic with
()
?