<i id='HRiAe'><tr id='HRiAe'><dt id='HRiAe'><q id='HRiAe'><span id='HRiAe'><b id='HRiAe'><form id='HRiAe'><ins id='HRiAe'></ins><ul id='HRiAe'></ul><sub id='HRiAe'></sub></form><legend id='HRiAe'></legend><bdo id='HRiAe'><pre id='HRiAe'><center id='HRiAe'></center></pre></bdo></b><th id='HRiAe'></th></span></q></dt></tr></i><div id='HRiAe'><tfoot id='HRiAe'></tfoot><dl id='HRiAe'><fieldset id='HRiAe'></fieldset></dl></div>

<tfoot id='HRiAe'></tfoot>

    1. <legend id='HRiAe'><style id='HRiAe'><dir id='HRiAe'><q id='HRiAe'></q></dir></style></legend>
    2. <small id='HRiAe'></small><noframes id='HRiAe'>

        <bdo id='HRiAe'></bdo><ul id='HRiAe'></ul>

    3. C++ Boost:这个警告的原因是什么?

      C++ Boost: what#39;s the cause of this warning?(C++ Boost:这个警告的原因是什么?)
      • <small id='5y7zF'></small><noframes id='5y7zF'>

          • <bdo id='5y7zF'></bdo><ul id='5y7zF'></ul>

            1. <i id='5y7zF'><tr id='5y7zF'><dt id='5y7zF'><q id='5y7zF'><span id='5y7zF'><b id='5y7zF'><form id='5y7zF'><ins id='5y7zF'></ins><ul id='5y7zF'></ul><sub id='5y7zF'></sub></form><legend id='5y7zF'></legend><bdo id='5y7zF'><pre id='5y7zF'><center id='5y7zF'></center></pre></bdo></b><th id='5y7zF'></th></span></q></dt></tr></i><div id='5y7zF'><tfoot id='5y7zF'></tfoot><dl id='5y7zF'><fieldset id='5y7zF'></fieldset></dl></div>
                <legend id='5y7zF'><style id='5y7zF'><dir id='5y7zF'><q id='5y7zF'></q></dir></style></legend>

                <tfoot id='5y7zF'></tfoot>
                  <tbody id='5y7zF'></tbody>
                本文介绍了C++ Boost:这个警告的原因是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我有一个带有 Boost 的简单 C++,如下所示:

                I have a simple C++ with Boost like this:

                #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(" "));
                

                这很好用;它将 ( ) 的每次出现替换为"

                This works fine; it replaces every occurrence of ( ) , with a " "

                但是,我在编译时收到此警告:

                However, I get this warning when compiling:

                我使用的是 MSVC 2008,Boost 1.37.0.

                I'm using MSVC 2008, Boost 1.37.0.

                1>Compiling...
                1>mainTest.cpp
                1>c:workminescout-feat-000extliboostalgorithmstringdetailclassification.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.0vcincludexutility(2576) : see declaration of 'std::copy'
                1>        c:workminescout-feat-000extliboostalgorithmstringclassification.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:workminescout-feat-000minescouttestmaintest.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
                

                但在我发现问题之前,或者更重要的是,如果我的代码不正确,我有点不愿意这样做.

                but I'm a bit reluctant to do that before I find out what's wrong, or more importantly if my code is incorrect.

                推荐答案

                没什么好担心的.在 MSVC 的最后几个版本中,他们进入了完全的安全偏执模式.std::copy 与原始指针一起使用时会发出此警告,因为如果使用不当,会导致缓冲区溢出.

                It is nothing to worry about. In the last few releases of MSVC, they've gone into full security-paranoia mode. std::copy issues this warning when it is used with raw pointers, because when used incorrectly, it can result in buffer overflows.

                他们的迭代器实现执行边界检查以确保不会发生这种情况,但性能成本很高.

                Their iterator implementation performs bounds checking to ensure this doesn't happen, at a significant performance cost.

                所以请随意忽略警告.这并不意味着您的代码有任何问题.这只是说如果你的代码有问题,那么糟糕的事情就会发生.发出警告是一件奇怪的事情.;)

                So feel free to ignore the warning. It doesn't mean there's anything wrong with your code. It is just saying that if there is something wrong with your code, then bad things will happen. Which is an odd thing to issue warnings about. ;)

                这篇关于C++ Boost:这个警告的原因是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                How to print vector#39;s data(如何打印矢量的数据)
                Visual C++ appends 0xCC (int3) bytes at the end of functions(Visual C++ 在函数末尾附加 0xCC (int3) 字节)
                How to use a variable inside a _T wrapper?(如何在 _T 包装器中使用变量?)
                MSVC++ warning flags(MSVC++ 警告标志)
                How to read file which contains uxxxx in vc++(如何在vc++中读取包含uxxxx的文件)
                stack overflow error in C++ program(C++程序中的堆栈溢出错误)

                  <bdo id='9dZ2o'></bdo><ul id='9dZ2o'></ul>
                    <i id='9dZ2o'><tr id='9dZ2o'><dt id='9dZ2o'><q id='9dZ2o'><span id='9dZ2o'><b id='9dZ2o'><form id='9dZ2o'><ins id='9dZ2o'></ins><ul id='9dZ2o'></ul><sub id='9dZ2o'></sub></form><legend id='9dZ2o'></legend><bdo id='9dZ2o'><pre id='9dZ2o'><center id='9dZ2o'></center></pre></bdo></b><th id='9dZ2o'></th></span></q></dt></tr></i><div id='9dZ2o'><tfoot id='9dZ2o'></tfoot><dl id='9dZ2o'><fieldset id='9dZ2o'></fieldset></dl></div>
                    <legend id='9dZ2o'><style id='9dZ2o'><dir id='9dZ2o'><q id='9dZ2o'></q></dir></style></legend>

                      <tbody id='9dZ2o'></tbody>
                      1. <tfoot id='9dZ2o'></tfoot>

                        <small id='9dZ2o'></small><noframes id='9dZ2o'>