struct WrappedInt { int x; }; void ?{}(WrappedInt * this) { printf("constructing int\n"); this->x = 0; } void ?{}(WrappedInt * this, WrappedInt other) { printf("copy constructing int: %d\n", other.x); this->x = other.x; } void ?{}(WrappedInt * this, int x) { printf("constructing int: %d\n", x); this->x = x; } void ^?{}(WrappedInt * this) { printf("destructing int: %d\n", this->x); } void ?=?(WrappedInt * this, int x) { printf("assigning int: %d %d\n", this->x, x); this->x = x; } struct A { WrappedInt x, y, z; }; void ?{}(A * a, int x) { (&a->x){ x+999 }; a->y = 0; // not a constructor - default constructor will be inserted } // z never constructed - will be automatically default constructed void ?{}(A * this, A other) { (&this->x){ other.x }; this->y = other.y; // not a constructor - copy constructor will be inserted } // z never constructed - will be automatically copy constructed struct B { A a1, a2, a3; }; void ?{}(B * b) { b->a2 = (A) { 2 }; (&b->a1){ 1 }; #ifdef ERR1 (&b->a2){ b->a3 }; // error, b->a2 was used previously but is explicitly constructed #endif } // a2, a3 never constructed - will be automatically default constructed void ^?{}(B * b) { b->a2 = (A) { 0 }; ^(&b->a1){}; } // a2, a3 never destructed - will be automatically destructed int main() { printf("Before declaration of b1\n"); B b1; printf("Before declaration of b2\n"); B b2 = b1; printf("End of main\n"); }