I have to fill std::vector elements of type struct MHD_OptionItem . This structure has the following implementation:
struct MHD_OptionItem { enum MHD_OPTION option; intptr_t value; void *ptr_value; };
I 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, tells me:
warning: extended initializer lists only available with -std=c++0x or -std=gnu++0x
I know that I can initialize a temporary structure and then pass it to a vector, but this method seems inefficient and not very elegant to me.
I cannot change the construction that inserts the constructor, because this is not my code, but a library.
Is there an elegant way to do this without using C ++ 0x syntax?
source share