2009-05-23 40 views
0

我使用Boost 1.38,并且我刚升级到1.39。升级打破了以下一段代码:从boost 1.38升级到1.39导致我的调用boost :: algorithm :: split不编译

std::vector<std::wstring> consoleParser::loadStringsFromFile(const std::wstring &fileName) 
{ 
    std::vector<std::wstring> files; 
    std::wstring fileString(loadFileAsString(fileName)); 
    boost::algorithm::split(files, fileString, boost::is_any_of(L"\r\n'\"")); //Error on this line 
    return files; 
} 

任何想法是什么导致失败?我的编译器发出有益如下:

c:\boost\boost\utility\addressof.hpp(30) : error C2220: warning treated as error - no 'object' file generated 
     c:\boost\boost\utility\addressof.hpp(56) : see reference to class template instantiation 'boost::detail::addr_impl_ref<T>' being compiled 
     with 
     [ 
      T=boost::algorithm::detail::token_finderF<boost::algorithm::detail::is_any_ofF<wchar_t>> 
     ] 
     c:\boost\boost\function\function_template.hpp(600) : see reference to function template instantiation 'T *boost::addressof<FunctionObj>(T &)' being compiled 
     with 
     [ 
      T=boost::algorithm::detail::token_finderF<boost::algorithm::detail::is_any_ofF<wchar_t>>, 
      FunctionObj=boost::algorithm::detail::token_finderF<boost::algorithm::detail::is_any_ofF<wchar_t>> 
     ] 
     c:\boost\boost\function\function_template.hpp(491) : see reference to function template instantiation 'bool boost::detail::function::basic_vtable2<R,T0,T1>::assign_to<F>(FunctionObj,boost::detail::function::function_buffer &,boost::detail::function::function_obj_tag)' being compiled 
     with 
     [ 
      R=boost::iterator_range<std::_String_iterator<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>>>, 
      T0=std::_String_iterator<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>>, 
      T1=std::_String_iterator<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>>, 
      F=boost::algorithm::detail::token_finderF<boost::algorithm::detail::is_any_ofF<wchar_t>>, 
      FunctionObj=boost::algorithm::detail::token_finderF<boost::algorithm::detail::is_any_ofF<wchar_t>> 
     ] 
     c:\boost\boost\function\function_template.hpp(906) : see reference to function template instantiation 'bool boost::detail::function::basic_vtable2<R,T0,T1>::assign_to<Functor>(F,boost::detail::function::function_buffer &)' being compiled 
     with 
     [ 
      R=boost::iterator_range<std::_String_iterator<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>>>, 
      T0=std::_String_iterator<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>>, 
      T1=std::_String_iterator<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>>, 
      Functor=boost::algorithm::detail::token_finderF<boost::algorithm::detail::is_any_ofF<wchar_t>>, 
      F=boost::algorithm::detail::token_finderF<boost::algorithm::detail::is_any_ofF<wchar_t>> 
     ] 
     c:\boost\boost\function\function_template.hpp(720) : see reference to function template instantiation 'void boost::function2<R,T0,T1>::assign_to<Functor>(Functor)' being compiled 
     with 
     [ 
      R=boost::iterator_range<std::_String_iterator<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>>>, 
      T0=std::_String_iterator<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>>, 
      T1=std::_String_iterator<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>>, 
      Functor=boost::algorithm::detail::token_finderF<boost::algorithm::detail::is_any_ofF<wchar_t>> 
     ] 
     c:\boost\boost\algorithm\string\detail\find_iterator.hpp(51) : see reference to function template instantiation 'boost::function2<R,T0,T1>::function2<FinderT>(Functor,int)' being compiled 
     with 
     [ 
      R=boost::iterator_range<std::_String_iterator<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>>>, 
      T0=std::_String_iterator<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>>, 
      T1=std::_String_iterator<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>>, 
      FinderT=boost::algorithm::detail::token_finderF<boost::algorithm::detail::is_any_ofF<wchar_t>>, 
      Functor=boost::algorithm::detail::token_finderF<boost::algorithm::detail::is_any_ofF<wchar_t>> 
     ] 
     c:\boost\boost\algorithm\string\find_iterator.hpp(261) : see reference to function template instantiation 'boost::algorithm::detail::find_iterator_base<IteratorT>::find_iterator_base<FinderT>(FinderT,int)' being compiled 
     with 
     [ 
      IteratorT=input_iterator_type, 
      FinderT=boost::algorithm::detail::token_finderF<boost::algorithm::detail::is_any_ofF<wchar_t>> 
     ] 
     c:\boost\boost\algorithm\string\iter_find.hpp(167) : see reference to function template instantiation 'boost::algorithm::split_iterator<IteratorT>::split_iterator<FinderT>(IteratorT,IteratorT,FinderT)' being compiled 
     with 
     [ 
      IteratorT=input_iterator_type, 
      FinderT=boost::algorithm::detail::token_finderF<boost::algorithm::detail::is_any_ofF<wchar_t>> 
     ] 
     c:\boost\boost\algorithm\string\split.hpp(149) : see reference to function template instantiation 'SequenceSequenceT &boost::algorithm::iter_split<SequenceSequenceT,RangeT,boost::algorithm::detail::token_finderF<PredicateT>>(SequenceSequenceT &,RangeT &,FinderT)' being compiled 
     with 
     [ 
      SequenceSequenceT=std::vector<std::wstring>, 
      RangeT=std::wstring, 
      PredicateT=boost::algorithm::detail::is_any_ofF<wchar_t>, 
      FinderT=boost::algorithm::detail::token_finderF<boost::algorithm::detail::is_any_ofF<wchar_t>> 
     ] 
     c:\documents and settings\user\my documents\visual studio 2008\projects\pevfind\pevfind\consoleparser.cpp(1529) : see reference to function template instantiation 'SequenceSequenceT &boost::algorithm::split<std::vector<_Ty>,std::wstring,boost::algorithm::detail::is_any_ofF<CharT>>(SequenceSequenceT &,RangeT &,PredicateT,boost::algorithm::token_compress_mode_type)' being compiled 
     with 
     [ 
      SequenceSequenceT=std::vector<std::wstring>, 
      _Ty=std::wstring, 
      CharT=wchar_t, 
      RangeT=std::wstring, 
      PredicateT=boost::algorithm::detail::is_any_ofF<wchar_t> 
     ] 
c:\boost\boost\utility\addressof.hpp(30) : warning C4512: 'boost::detail::addr_impl_ref<T>' : assignment operator could not be generated 
     with 
     [ 
      T=boost::algorithm::detail::token_finderF<boost::algorithm::detail::is_any_ofF<wchar_t>> 
     ] 

回答

3

由于发出新警告(boost::detail::addr_impl_ref<T>' : assignment operator could not be generated),您的编译失败,并且您的设置被设置为将警告视为错误。从thisthis来看,这确实是Boost 1.39.0和VS2008的问题。

后一个链接提供了修补问题的补丁。它应该在Boost 1.40.0中修复。

另一种方法是暂时禁用“将警告视为错误”标志。

1

如果我切换到警戒水位4和设置警告视为错误矿山打破了。 尝试更改这些设置。

0

我真的不喜欢“警告视为错误”对于这种原因,但你可以这样做:

#pragma warning (disable:4512) 

上面addressof.hpp任何#include行。