1

Possible Duplicate:
C++ Boost: what’s the cause of this warning?

This code is taken from the boost docs http://www.boost.org/doc/libs/1_51_0/doc/html/string_algo/usage.html#id3240174

    using namespace boost;
    string str1("hello abc-*-ABC-*-aBc goodbye");
    typedef vector< string > split_vector_type;
    split_vector_type SplitVec;
    split( SplitVec, str1, is_any_of("-*"), token_compress_on ); 

I get nasty compiler warnings

1>c:\program files\boost\boost_1_51\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(2550) : see declaration of 'std::copy'
1>        c:\program files\boost\boost_1_51\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_type *,
1>            RangeT=boost::iterator_range<const char_type *>
1>        ]
1>        c:\users\james\code\ecrew\work\src\cinstrumentpanel.cpp(71) : see reference to function template instantiation 'boost::algorithm::detail::is_any_ofF<CharT> boost::algorithm::is_any_of<const char[3]>(RangeT (&))' being compiled
1>        with
1>        [
1>            CharT=char,
1>            RangeT=const char [3]
1>        ]

Why?

How can I get rid of the warnings, other than simply sup[ressing them with _SCL_SECURE_NO_WARNINGS

boost version 1.51

MSVSC2008

Community
  • 1
  • 1
ravenspoint
  • 19,093
  • 6
  • 57
  • 103
  • Warnings like this are enabled by default in order to prevent beginners from making common beginner errors, because beginners wouldn't know how to enable such a feature if it was not enabled by default. You don't seem to be a beginner, disable the warning. – Benjamin Lindley Nov 07 '12 at 18:01
  • 1
    As to "Why?", it's because inside `boost::split`, it uses pointers as iterators, which it apparently passes to `std::copy`. These cannot be checked by Visual C++'s "Checked Iterators" machinery, and so a warning is thrown. – Benjamin Lindley Nov 07 '12 at 18:06

0 Answers0