fork(1) download
  1. #include <initializer_list>
  2. #include <array>
  3.  
  4. template<typename T, int N>
  5. struct my_array
  6. {
  7.  
  8. constexpr my_array(const std::array<T, N> & l)
  9. {
  10. }
  11. };
  12.  
  13. int main(int argc, char ** argv)
  14. {
  15. my_array<int, 2> a{{1, 2}};
  16. my_array<int, 1> b{{1, 2}};
  17.  
  18. return 0;
  19. }
  20.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main(int, char**)':
prog.cpp:16:27: error: no matching function for call to 'my_array<int, 1>::my_array(<brace-enclosed initializer list>)'
  my_array<int, 1> b{{1, 2}};
                           ^
prog.cpp:8:12: note: candidate: constexpr my_array<T, N>::my_array(const std::array<T, N>&) [with T = int; int N = 1]
  constexpr my_array(const std::array<T, N> & l)
            ^
prog.cpp:8:12: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::array<int, 1u>&'
prog.cpp:5:8: note: candidate: constexpr my_array<int, 1>::my_array(const my_array<int, 1>&)
 struct my_array
        ^
prog.cpp:5:8: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const my_array<int, 1>&'
prog.cpp:5:8: note: candidate: constexpr my_array<int, 1>::my_array(my_array<int, 1>&&)
prog.cpp:5:8: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'my_array<int, 1>&&'
stdout
Standard output is empty