【发布时间】:2011-08-23 06:44:44
【问题描述】:
我正在尝试将boost::bind 和STL 与boost::tuple 一起使用,但每次尝试编译时都会出现以下错误。
error: call of overloaded ‘bind(<unresolved overloaded function type>,
boost::arg<1>&)’ is ambiguous
你知道我在这里做错了什么吗?为什么只针对boost::arg<1>?
谢谢 自动对焦
#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?get不是boost命名空间中的东西吗?不是这个eth_array命名空间/类? -
auch ..我在复制代码时已更改。已在上述示例中修复。
标签: c++ stl boost-bind boost-tuples