boost::make_function_output_iterator报错: C4996
用VS2013运行boost::make_function_output_iterator的官方例子:
https://www.boost.org/doc/libs/1_68_0/libs/iterator/doc/function_output_iterator.html
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
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;} |
结果报如下的编译错误:
|
1
|
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
|
[解决方法]
加入预处理器(项目属性----C/C++----预处理----预处理器定义):
_SCL_SECURE_NO_WARNINGS
[分析]
这个编译错误是由于vc++的checked iterators规则(https://msdn.microsoft.com/en-us/library/aa985965.aspx), 加入_SCL_SECURE_NO_WARNINGS预处理器后, 编译会通过,然后将风险交给运行时,由于boost库比较完善,所以这种风险应该不存在.
把链接中的Checked iterators内容拷贝如下:
Checked IteratorsVisual Studio 2015
Other Versions
Checked iterators ensure that the bounds of your container are not overwritten. Checked iterators apply to both release builds and debug builds. For more information about how to use debug iterators when you compile in debug mode, see Debug Iterator Support. For information about how to disable warnings that are generated by checked iterators, see _SCL_SECURE_NO_WARNINGS. You can use the _ITERATOR_DEBUG_LEVEL preprocessor macro to enable or disable the checked iterators feature. If
When
When
A checked iterator refers to an iterator that will call checked_array_iterator Class and unchecked_array_iterator Class are the iterator adaptors that support checked iterators. When you compile by using // checked_iterators_1.cpp This program prints "67" then pops up an assertion failure dialog box with additional information about the failure. Similarly, when you compile by using // checked_iterators_2.cpp This program pops up an assertion failure dialog box with additional information about the failure. The following code demonstrates various iterator use-case scenarios with comments about each. By default, // checked_iterators_3.cpp When you compile this code by using algorithm(1026) : warning C4996: 'std::_Transform1': Function call with parameters When run at the command line, the executable generates this output: v: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
boost::make_function_output_iterator报错: C4996的更多相关文章
- boost pool_allocator 报错 'rebind'
#include "stdafx.h" #include <vector> #include <boost/pool/pool.hpp> int _tmai ...
- 在Visual Studio 2019中使用scanf报错C4996解决办法
错误警告信息 错误C4996 'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To ...
- C++解决error C4996报错
今天用c++写了个数独程序,在编译过程中报了一个错误: 1>------ 已启动生成: 项目: sudoku, 配置: Debug Win32 ------1> main.cpp1> ...
- GCC 高版本7.4 编译链接 boost 报错 boost::thread::XXX’未定义的引用 解决方法
背景:开发中的项目之前一直用GCC4.8,boost库1.48版本的开发环境.现在因业务需求,需要更换GCC7.4,boost库1.70. 问题:可以正常编译BOOST的链接库文件,但是链接时候报错. ...
- 16061701(地图灯光编译Beast报错)
[目标] 地图灯光编译报错 [思路] 1 我自己测c2_cwd_rt 附件为当时log 2 ExampleGame\BeastCache\PersistentCache 3 重新删除掉BeastCac ...
- caffe ubuntu16安装报错和程序总结
我最近安装安装了老版本的caffe,安装过程真是两个字"想死",所以我的错误一般都是比较经典的. 我是使用cuda的版本,所以可能会出现undefined refference t ...
- caffe编译报错解决
添加ssd中的一些层之后,编译报错: ../lib/libcaffe.so.1.0.0-rc5:对‘boost::match_results<__gnu_cxx::__normal_iterat ...
- 【PaddlePaddle系列】报错解决方法合集 (不定时更新)
1.PaddlePaddle使用CPU时正常运行,但是使用GPU时却报出一堆错误信息,节选如下: paddle.fluid.core.EnforceNotMet: enforce allocating ...
- 。。。。。。不带http https : 不报错 spring boot elasticsearch rest
......不带http https : 不报错 先telnet http://onf:8080/getES653/道路桥梁正在“理疗”%20这14条道路纳入市政中修 @GetMapping(&qu ...
随机推荐
- spring security学习
https://www.cnblogs.com/leihenqianshang/articles/5313159.html
- Zookeeper三个监听案例
一.监听某一节点内容 /** * @author: PrincessHug * @date: 2019/2/25, 14:28 * @Blog: https://www.cnblogs.com/Hel ...
- SQL-内连接、外连接(左、右)、交叉连接
本文测试基于以下两个表,student(左) \ teacher(右),使用数据库MariaDB,图形化界面HeidiSQL. 连接查询的概念:根据两个表或多个表的列之间的关系,从这些表中查询数据,即 ...
- Jmeter实现Basic Auth方式登录
背景 在实际测试日常中,产品有两种登录方式,一种是普通登录方式,另一种则是Basic Auth方式登录.两种登录对应着产品中不同的操作,对权限进行了一个划分. Postman登录 使用Postman登 ...
- APP开发,微信第三方登录的介绍
去年做了一阵APP相关的开发,经常遇到第三方登陆的需求,比如微信.微博.fb的第三方登陆等等,其实主要的流程都大同小异,这里就以微信为例来介绍,希望对大家有帮助. 微信开放平台(open.weixin ...
- shiro学习总结(一)----初识shiro
本系列内容大多总结自官网和张开涛的<跟我学Shiro> 一.shiro简介 1.1.shiro有什么用? shiro是一个功能强大使用简单的java安全框架,主要提供了五大功能: 1.认证 ...
- linux 学习笔记 查看端口
查看端口 #lsof -i :端口号 |\根据端口号查看进程信息 例如:#lsof -i:8080 command pid user fd type device size node java ...
- 说说我安装pyspider遇到的那些坑
现在python3.7 >>pip install pyspider 配置环境变量 前置的phantomjs 无界面浏览器,设置就不说了 cmd 中运行pyspider all ...
- python 条件与循环
一.if语句 1.1 功能 计算机又被称作电脑,意指计算机可以像人脑一样,根据周围环境条件(即expession)的变化做出不同的反应(即执行代码) if语句就是来控制计算机实现这一功能 1. ...
- 845. Greatest Common Divisor
描述 Given two numbers, number a and number b. Find the greatest common divisor of the given two numbe ...
Important