我有一个简单的C++与升压像这样:C++ Boost:这个警告的原因是什么?
#include <boost/algorithm/string.hpp>
int main()
{
std::string latlonStr = "hello,ergr()()rg(rg)";
boost::find_format_all(latlonStr,boost::token_finder(boost::is_any_of("(,)")),boost::const_formatter(" "));
也能正常工作;它取代的每次出现(),着有“”
不过,我得到编译时这样的警告:
我使用MSVC 2008年,升压1.37.0。
1>Compiling...
1>mainTest.cpp
1>c:\work\minescout-feat-000\extlib\boost\algorithm\string\detail\classification.hpp(102) : warning C4996: 'std::copy': 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'
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\xutility(2576) : see declaration of 'std::copy'
1> c:\work\minescout-feat-000\extlib\boost\algorithm\string\classification.hpp(206) : see reference to function template instantiation 'boost::algorithm::detail::is_any_ofF<CharT>::is_any_ofF<boost::iterator_range<IteratorT>>(const RangeT &)' being compiled
1> with
1> [
1> CharT=char,
1> IteratorT=const char *,
1> RangeT=boost::iterator_range<const char *>
1> ]
1> c:\work\minescout-feat-000\minescouttest\maintest.cpp(257) : see reference to function template instantiation 'boost::algorithm::detail::is_any_ofF<CharT> boost::algorithm::is_any_of<const char[4]>(RangeT (&))' being compiled
1> with
1> [
1> CharT=char,
1> RangeT=const char [4]
1> ]
我当然可以禁用使用
-D_SCL_SECURE_NO_WARNINGS
的警告,但我有点不愿意这样做之前,我找出什么是错的,或者更重要的是,如果我的代码不正确。
这个警告让我发疯,它就像一杯咖啡热的“警告”。 – Clay 2009-08-19 17:20:02
最糟糕的是没有理智的“修复”。发布大多数警告是因为有更好的,更容易出错的方式来实现相同的目的。他们可以*固定*。你应该怎么做这件事?如果您有一个原始C数组,并且您需要将数据复制到其中或从中复制数据,则指针是唯一可用的迭代器类型。 std :: copy是迄今为止使用的最安全的选项。还是他们建议我们回去写循环来达到同样的目的? – jalf 2009-08-19 17:58:38
我敢打赌100代表,它会在第一个SP和其他“不测试他们发布的东西吗?”中被删除。问题... – 2010-12-19 16:03:23