fork(1) download
  1. #include <iostream>
  2.  
  3. template <std::size_t SIZE> class A
  4. {
  5. char b[SIZE];
  6.  
  7. public:
  8. using const_buffer_t = const char (&)[SIZE];
  9.  
  10. A() : b{} { std::cout << "size: " << SIZE << " ctor 1\n"; }
  11. A(const_buffer_t) : b{} { std::cout << "size: " << SIZE << " ctor 2\n"; }
  12. A(const char*, std::size_t) : b{} { std::cout << "size: " << SIZE << " ctor 3\n"; }
  13. explicit A(const A&) : b{} { std::cout << "size: " << SIZE << " ctor 4\n"; }
  14.  
  15. template <std::size_t OTHER_SIZE>
  16. A(const char (&)[OTHER_SIZE]) : b{} { std::cout << "size: " << SIZE << " ctor 5\n"; }
  17.  
  18. template <std::size_t OTHER_SIZE>
  19. explicit A(const A<OTHER_SIZE> &) : b{} { std::cout << "size: " << SIZE << " ctor 6\n"; }
  20. };
  21.  
  22. int main()
  23. {
  24. A<5> a("five");
  25. A<5> b("0123456789");
  26. A<9> c(a);
  27. A<5> d;
  28. A<5> e(d);
  29. A<9> f(d);
  30. }
  31.  
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
size: 5 ctor 2
size: 5 ctor 5
size: 9 ctor 6
size: 5 ctor 1
size: 5 ctor 4
size: 9 ctor 6