【发布时间】:2012-02-26 16:55:50
【问题描述】:
以下两种情况有什么区别?
std::pair<int,std::string> example_1 (std::make_pair (1,"foo"));
int value_1 = boost::bind (&std::pair<int,std::string>::first,_1) (example_1);
std::map<int,std::string>::value_type example_2 (std::make_pair (2,"boo"));
int value_2 = boost::bind (&std::pair<int,std::string>::first,_1) (example_2);
第一个示例运行良好,但第二个示例在绑定完成后无法编译。我看过文件stl_map.h和value_type定义如下:
typedef std::pair<const _Key, _Tp> value_type;
我看不出有什么不同。如果有人能告诉我,以及第二个示例无法编译的原因,我将不胜感激。
编译错误信息为:
.../include/boost/bind/mem_fn.hpp:333:36: error: no matching function for call to ‘get_pointer(const std::pair<const int, std::basic_string<char> >&)’
make: *** [main.o] Error 1
提前致谢!
【问题讨论】:
标签: c++ boost stl boost-bind