boost::make_function_output_iterator报错: C4996

time_is_life 2018-08-28 11:54:58
用VS2013运行boost::make_function_output_iterator的官方例子:
https://www.boost.org/doc/libs/1_68_0/libs/iterator/doc/function_output_iterator.html


struct string_appender
{
string_appender(std::string& s)
: m_str(&s)
{}

void operator()(const std::string& x) const
{
*m_str += x;
}

std::string* m_str;
};

int main(int, char*[])
{
std::vector<std::string> x;
x.push_back("hello");
x.push_back(" ");
x.push_back("world");
x.push_back("!");

std::string s = "";
std::copy(x.begin(), x.end(),
boost::make_function_output_iterator(string_appender(s)));

std::cout << s << std::endl;

return 0;
}



结果报如下的编译错误:

Error 1 error C4996: 'std::_Copy_impl': Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked Iterators' c:\program files (x86)\microsoft visual studio 12.0\vc\include\xutility 2132 1



怎么解决,请高手指教,谢谢.
...全文
145 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
sghcpt 2018-08-28
  • 打赏
  • 举报
回复
楼主,试试下面方法:
加入预处理器(项目属性----C/C++----预处理----预处理器定义):
_SCL_SECURE_NO_WARNINGS

64,648

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧