I have to fill a std::vector with elements of type struct MHD_OptionItem.
This struct have this implementation:
struct MHD_OptionItem
{
enum MHD_OPTION option;
intptr_t value;
void *ptr_value;
};
I have tried this way:
vector<struct MHD_OptionItem> iov;
if(...)
iov.push_back({ MHD_OPTION_NOTIFY_COMPLETED, requestCompleted, NULL });
if(...)
iov.push_back({ MHD_OPTION_CONNECTION_TIMEOUT, connectionTimeout });
[....]
but the g++ compiler, as expected, says to me:
warning: extended initializer lists only available with -std=c++0x or -std=gnu++0x
I know that I can initialize a temporary struct and then pass it to the vector, but this method seems to me to be inefficient and not so elegant.
I can’t change the struct inserting a constructor because this is not my code but a library included.
There is an elegant way to do this without using c++0x syntax?
Assuming you cannot change the
structor you want to leave it a POD:Another solution: