Hi I am working through some C++ issues and I'm not familiar with the language.
I am trying to initialize a std::pair, double> with this syntax:
std::pair<std::vector<int>, double> output = { {}, 0.0f };
gcc 5.4.0 on Ubuntu 16.04 generates this error:
no known conversion for argument 1 from ‘std::pair<std::vector<int>, double>’ to ‘std::initializer_list<int>
The same error happens if I use this syntax:
std::pair<std::vector<int>, double> output{{}, 0.0f };
What is the issue?
You are using an extended initializer list (std::initializer_list) which is available since C++11.
For the gcc 5.4.0 compiler, you need to compile it with C++11 flag:
$ g++ main.cpp -std=c++11
https://gcc.godbolt.org/z/SHzREE
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With