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