fork download
  1. #include <vector>
  2.  
  3. struct curl_a {
  4. curl_a(){};
  5. curl_a(int * d, int &l) :data(d), logged(l){};
  6. int * data;
  7. bool logged;
  8. };
  9.  
  10. int main()
  11. {
  12. std::vector<curl_a> foo;
  13. curl_a f;
  14. foo.push_back({ &x, true });
  15. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:14:19: error: ‘x’ was not declared in this scope
  foo.push_back({ &x, true });
                   ^
prog.cpp:14:28: error: no matching function for call to ‘std::vector<curl_a>::push_back(<brace-enclosed initializer list>)’
  foo.push_back({ &x, true });
                            ^
prog.cpp:14:28: 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 = curl_a; _Alloc = std::allocator<curl_a>; std::vector<_Tp, _Alloc>::value_type = curl_a]
       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 curl_a&}’
/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 = curl_a; _Alloc = std::allocator<curl_a>; std::vector<_Tp, _Alloc>::value_type = curl_a]
       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<curl_a>::value_type&& {aka curl_a&&}’
stdout
Standard output is empty