首页 > 其他 > 详细

no matching function for call to 'make_pair(std::string&, size_t&)'

时间:2017-10-20 15:31:34      阅读:2427      评论:0      收藏:0      [点我收藏+]
rtl->push_back(make_pair<string, int>(str, pos));

在redhat6上编译无问题,在centos7上编译出现错误:

no matching function for call to make_pair(std::string&, size_t&)

,这是由于

1 定义于头文件 <utility>
2 template< class T1, class T2 >
3 std::pair<T1,T2> make_pair( T1 t, T2 u );//(C++11 前)
4 template< class T1, class T2 >
5 std::pair<V1,V2> make_pair( T1&& t, T2&& u );//(C++11 起)-(C++14 前)
6 template< class T1, class T2 >
7 constexpr std::pair<V1,V2> make_pair( T1&& t, T2&& u );//(C++14 起)

make_pair在c++11前后修改了声明,对于该错误,有两种修改方式:

1、make_pair(str, pos)

2、make_pair<string, int>(string(str), int(pos))

no matching function for call to 'make_pair(std::string&, size_t&)'

原文:http://www.cnblogs.com/zl1991/p/7699510.html

(0)
(2)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!