#include <vector>
struct curl_a {
curl_a(){};
curl_a(int * d, int &l) :data(d), logged(l){};
int * data;
bool logged;
};
int main()
{
std::vector<curl_a> foo;
curl_a f;
foo.push_back({ &x, true });
}
I2luY2x1ZGUgPHZlY3Rvcj4KCnN0cnVjdCBjdXJsX2EgewoJY3VybF9hKCl7fTsKCWN1cmxfYShpbnQgKiBkLCBpbnQgJmwpIDpkYXRhKGQpLCBsb2dnZWQobCl7fTsKCWludCAqIGRhdGE7Cglib29sIGxvZ2dlZDsKfTsKCmludCBtYWluKCkKewoJc3RkOjp2ZWN0b3I8Y3VybF9hPiBmb287CgljdXJsX2EgZjsKCWZvby5wdXNoX2JhY2soeyAmeCwgdHJ1ZSB9KTsKfQ==
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&&}’