错误 C4996:"std::_Copy_impl":禁用它是否安全?
error C4996: 'std::_Copy_impl': is it safe to disable it?
我使用odeint boost来求解微分方程。在visual studio 2010中,没有错误显示,但当我使用visual studio 2013时,我得到这个错误
xutility(2132): 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'
我已经通过使用这个#pragma warning( disable : 4996 )
禁用警告解决了这个问题,odeint中提供的示例现在正在工作。这是示例,
#pragma warning( disable : 4996 )
#include <iostream>
#include <boost/array.hpp>
#include <boost/numeric/odeint.hpp>
using namespace std;
using namespace boost::numeric::odeint;
const double sigma = 10.0;
const double R = 28.0;
const double b = 8.0 / 3.0;
typedef boost::array< double, 3 > state_type;
void lorenz(const state_type &x, state_type &dxdt, double t)
{
dxdt[0] = sigma * (x[1] - x[0]);
dxdt[1] = R * x[0] - x[1] - x[0] * x[2];
dxdt[2] = -b * x[2] + x[0] * x[1];
}
void write_lorenz(const state_type &x, const double t)
{
cout << t << 't' << x[0] << 't' << x[1] << 't' << x[2] << endl;
}
int main(int argc, char **argv)
{
state_type x = { 10.0, 1.0, 1.0 }; // initial conditions
integrate(lorenz, x, 0.0, 25.0, 0.1, write_lorenz);
}
我的问题是禁用此警告是否安全?由于
代码应该是安全的。我们在odeint的单元测试中禁用了相同的警告。
相关文章:
- 通过网络、跨平台传递std::变体是否安全
- 在类型和包装器之间reinterpret_cast是否安全<Type>?
- 跨 DLL 边界访问虚拟方法是否安全/可能?
- 静态 constexpr 类成员变量对多线程读取是否安全?
- 在函数结束后使用指向变量的指针是否安全?
- 逐字节删除 void* 是否安全?
- 在 RAII 构造中修改 RVO 值是否安全?
- 线程调用的函数对对象删除是否安全?
- 将对象的字节复制到数组并再次复制回来是否安全
- 使用枚举为数组编制索引是否安全?
- 返回从字符串文本创建的静态string_view是否安全?
- 在cstlib中将#include_next替换为#include是否安全
- 由并发无序映射查找线程调用的函数是否安全?
- 使用 c++ 原子时编写"y=++x"是否安全?
- 从另一个线程发出信号是否安全?
- 从其存储的回调中删除 std::函数是否安全
- 使用 std::vector::swap 方法在C++中交换两个不同的向量是否安全?
- 当我在C++中调用 struce 的只读静态成员时,线程是否安全
- 同时调用 ASIO 对象的 API 是否安全?
- 使用自己的迭代器分配容器是否安全?