Traditional task of iterating trough key set of std::map led me to another mess which seems not to be disscused here yet.
In short, this code does not compile (C++11 is heavily used):
typedef std::pair<int, int> Pair;
vector<Pair> v {Pair(1,2), Pair(2,3)};
using namespace std::placeholders;
auto choose_first = std::bind(&Pair::first, _1);
boost::make_transform_iterator(v.begin(), choose_first);
Error message is as follows.
no type named 'result_type' in 'struct std::_Bind<std::_Mem_fn<int std::pair<int, int>::*>(std::_Placeholder<1>)>'
At the same time, changing std::bind to boost::bind fixes the problem. But there is a code convention in my project that we use std::bind only.
Any suggestions what to do with this? (Should I write bugreport to the Boost team?)
There are better ways to iterate over the keys of a
std::map(or any container whosevalue_typeispair<T,U>), namely Boost.Range‘smap_keysadaptor (there’s also amap_valuesone):But back to your problem: All Boost libraries use the Boost.Utility function
result_of, which won’t fall back tostd::result_offor whatever reason, and also won’t usedecltypeif it’s available without you telling it to. You do so by putting#define BOOST_RESULT_OF_USE_DECLTYPEbefore the first Boost include.That, however, still didn’t make your code compile with Clang 3.1 SVN + libc++. Here’s the code I used:
Compiled with:
GCC 4.7 seems to accept this just fine, so I guess it’s a bug in libc++.