C++博客 首页 新随笔 联系 聚合 管理
  217 Posts :: 61 Stories :: 32 Comments :: 0 Trackbacks
在vs2012上编译了一下,发现有问题:error C4996: 'std::_Copy_impl': Function call with para


You haven't done anything wrong. Visual Studio is being overly cautious. In debug mode, visual studio uses something called "Checked Iterators". Pointers are also iterators, but the checking mechanism doesn't work with them. So when a standard library algorithm is called with pointers, which is something that boost::split does, it issues this warning.

You'll get the same warning with this obviously safe code:

int main()
    int x[10] = {};
    int y[10] = {};
    int *a = x, *b = y;
    std::copy(a, a+10, b);

Disable the warning. It's for beginners. It's on by default for the safety of beginners, because if it was off by default, they wouldn't know how to turn it on.

#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string.hpp>
void LearnSplit()
    std::string strTem("1,2,3,4");
    std::list<std::string> listStrTem;
    std::vector<std::string> vectorStrTem;
    boost::split(listStrTem, strTem, boost::is_any_of(","));
    boost::split(vectorStrTem, strTem, boost::is_any_of(","));
    for(auto item : listStrTem)
        std::cout << item.c_str() << std::endl;
    std::string s = "Hello, the beautiful world!";
    std::vector<std::string> rs;
    boost::split( rs, s, boost::is_any_of( " ,!" ), boost::token_compress_on );
int _tmain(int argc, _TCHAR* argv[])
return 0;
posted on 2013-04-11 00:29 Enic 阅读(961) 评论(0)  编辑 收藏 引用 所属分类: boost

【推荐】超50万行VC++源码: 大型组态工控、电力仿真CAD与GIS源码库
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理