In this response, tloveless pointed out that it\'s possible in MSVC to use this->foo::foo(42);
for constructor delegation to directly call a con
It is not constructor delegating. Try following code:
#include <iostream>
class C{
public:
C() { std::cout << "C" << std::endl; }
~C() { std::cout << "~C" << std::endl; }
};
struct foo
{
int m;
C c;
foo(int p) : m(p) { std::cout << "foo("<<p<<")\n"; }
foo()
: m(0)
{
this->foo::foo(42);
std::cout << "foo(), " << m << "\n";
}
};
int main()
{
foo f;
}
According to output field "c" is initialized twice but destroyed only once. As zneak noted, It is similar to new (this) foo(42)
.