E
eriwik
Consider this:
#inlcude <list>
struct elem {
int col;
int val;
};
int main() {
std::list<elem> l;
l.push_back(elem e={1,1}); // Error
elem e = {1,1};
l.push_back(e); // OK
return 0;
}
Is there any way to make the non-working line work without adding a
constructor to elem? What I want to do is to create an anonymous struct
and pass it as an argument to a function using initialization. It's not
particulary important, it's just been bugging me for some time now.
#inlcude <list>
struct elem {
int col;
int val;
};
int main() {
std::list<elem> l;
l.push_back(elem e={1,1}); // Error
elem e = {1,1};
l.push_back(e); // OK
return 0;
}
Is there any way to make the non-working line work without adding a
constructor to elem? What I want to do is to create an anonymous struct
and pass it as an argument to a function using initialization. It's not
particulary important, it's just been bugging me for some time now.