fork(1) download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class Inner2 {
  6. public:
  7. Inner2() { cout << "Inner2()" << endl; }
  8. };
  9.  
  10. class Inner1 {
  11. public:
  12. Inner1() : inner2(Inner2()) {
  13. cout << "Inner1()" << endl;
  14. }
  15. Inner2 inner2;
  16. };
  17.  
  18. Inner1 makeInner1() { return Inner1(); }
  19.  
  20. class Hoge {
  21. public:
  22. Hoge() : Hoge(makeInner1()) {
  23. cout << "Hoge()" << endl;
  24. }
  25.  
  26. Hoge(Inner1 &&inner1) : Hoge(std::move(inner1.inner2)) {
  27. cout << "Hoge(Inner1 &&)" << endl;
  28. }
  29.  
  30. Hoge(Inner2 &&inner2) : inner2(inner2) {
  31. cout << "Hoge(Inner2 &&)" << endl;
  32. }
  33.  
  34. private:
  35. Inner2 inner2;
  36. };
  37.  
  38. int main(){
  39. Hoge h;
  40. return 0;
  41. }
  42.  
  43.  
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
Inner2()
Inner1()
Hoge(Inner2 &&)
Hoge(Inner1 &&)
Hoge()