cxx-benchmarks/test-base-constr.cpp

31 rivejä
506 B
C++

#include <iostream>
#define L(s) std::cerr << s << "\n"
struct A {
A() { L("A::A()"); }
A(A&&) { L("A::A(A&&)"); }
A(const A&) { L("A::A(const A&)"); }
~A() { L("A::~A()"); }
};
struct B: A {
B() { L("B::B()"); }
B(A&&) { L("B::B(A&&)"); }
//B(B&&) { L("B::B(B&&)"); }
B(const A&) { L("B::B(const A&)"); }
// B(const B&) { L("B::B(const B&)"); }
~B() { L("B::~B()"); }
};
int main() {
L("A a1;");
A a1;
L("B b1(a1);");
B b1(a1);
L("B b1(b1);");
B b2(static_cast<A&>(b1));
return 0;
}