fork(1) download
  1. #include <vector>
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. struct vec2i{int x;int y;};
  6. struct t_quad{vec2i pos;vec2i size;t_quad(){}};
  7.  
  8. int main() {
  9. vector<t_quad> arr;
  10. arr.push_back({{0,0},{10,20}});
  11. cout<<arr.size();
  12. return 0;
  13. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:10:32: error: no matching function for call to ‘std::vector<t_quad>::push_back(<brace-enclosed initializer list>)’
   arr.push_back({{0,0},{10,20}});
                                ^
prog.cpp:10:32: note: candidates are:
In file included from /usr/include/c++/4.8/vector:64:0,
                 from prog.cpp:1:
/usr/include/c++/4.8/bits/stl_vector.h:901:7: note: void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = t_quad; _Alloc = std::allocator<t_quad>; std::vector<_Tp, _Alloc>::value_type = t_quad]
       push_back(const value_type& __x)
       ^
/usr/include/c++/4.8/bits/stl_vector.h:901:7: note:   no known conversion for argument 1 from ‘<brace-enclosed initializer list>’ to ‘const value_type& {aka const t_quad&}’
/usr/include/c++/4.8/bits/stl_vector.h:919:7: note: void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = t_quad; _Alloc = std::allocator<t_quad>; std::vector<_Tp, _Alloc>::value_type = t_quad]
       push_back(value_type&& __x)
       ^
/usr/include/c++/4.8/bits/stl_vector.h:919:7: note:   no known conversion for argument 1 from ‘<brace-enclosed initializer list>’ to ‘std::vector<t_quad>::value_type&& {aka t_quad&&}’
stdout
Standard output is empty