Here is the following code (assuming id and speed are already initialised, and includes are correct):
std::map<int, std::tuple<double, double>> mymap;
mymap.insert(std::pair<int, std::tuple<double, double>>(id, speed));
This code compiles and works under Macos (Xcode using clang-800.0.42.1) and Linux (Ubuntu 16.04, gcc 5.4.0).
mymap.insert(std::tie(id, speed));
This code compiles and works under Macos (Xcode using clang-800.0.42.1), but not under Linux (Ubuntu 16.04, gcc 5.4.0). For the latter, the error raised is:
error: no matching function for call to 'std::map<int, std::tuple<double, double> >::insert(std::tuple<int&, std::tuple<double, double>&>)
Note that the problem is similar when trying to insert an std::tuple to an std::map (bypassed by using std::pair instead of std::tuple).
Can anyone explain? Thanks!
Tuples are added to C++ form C++11.
For use of C++11 features you need to add -std=c++11 flag to your gcc compiler by default it is not activated yet.
I think mac compiles because you are using Xcode and maybe the -std=c++11 flag is already set from IDA.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.