我想使用boost::bind
和STL與boost::tuple
,但每次我嘗試編譯時出現以下錯誤。boost :: bind不能使用boost :: tuple :: get <N>()
error: call of overloaded ‘bind(<unresolved overloaded function type>,
boost::arg<1>&)’ is ambiguous
你知道我在做什麼錯在這裏,爲什麼只爲boost::arg<1>
?
感謝 AFG這裏
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <boost/tuple/tuple.hpp>
#include <boost/assign.hpp>
#include <boost/bind.hpp>
int main(int argc, const char** argv){
using namespace boost::assign;
typedef boost::tuple< int, double > eth_array;
std::vector<eth_array> v;
v+= boost::make_tuple(10,23.4), boost::make_tuple(12,24.4));
std::for_each(v.begin()
, v.end()
, boost::bind<int>(
printf
, "%d-%f"
, boost::bind(eth_array::get<0>, _1)
, boost::bind(eth_array::get<1>, _1)
)
);
什麼是「eth_array」? 'boost'命名空間中沒有'獲取'某些東西嗎?不是這個'eth_array'命名空間/類? –
auch ..我在複製代碼時已更改。在上面的示例中已修復。 –