Please use boost/bind/bind.hpp + using namespace boost::placeholders
程序员文章站
2022-05-31 21:57:47
...
The practice of declaring the Bind placeholders (_1, _2, …) in the global namespace is deprecated. Please use <boost/bind/bind.hpp> + using namespace boost::placeholders, or define BOOST_BIND_GLOBAL_PLACEHOLDERS to retain the current behavior.
- 提示warning的代码
#include <iostream>
#include <boost/bind.hpp>
using namespace std;
using namespace boost;
int fun(int x, int y) {return x+y;}
int main() {
int m=1, n=2;
cout << boost::bind(fun, _1, _2)(m, n) << endl;
return 0;
}
- 消除warning
#include <iostream>
#include <boost/bind/bind.hpp>
using namespace std;
using namespace boost::placeholders;
int fun(int x, int y) {return x+y;}
int main() {
int m=1, n=2;
cout << boost::bind(fun, _1, _2)(m, n) << endl;
return 0;
}
关注我的公众号
上一篇: InnoDB支持创建压缩数据页