#include <boost/algorithm/string.hpp>
#include <vector>
#include <iostream>
#include <string>
using namespace std;
using namespace boost;
int main(int, char **)
{
string test = "h:help";
vector<string> v;
iter_split(v, test, first_finder("h:"));
copy(v.begin(), v.end(), ostream_iterator<string>(cout, "\n"));
return 0;
}
Этот простой код не будет компилироваться в GCC 4.6 с использованием -std=c++0x
;однако он прекрасно скомпилируется как в более старом компиляторе (4.2), так и без режима C ++ 0x.
Вывод сообщения об ошибке:
In file included from /usr/include/boost/algorithm/string/split.hpp:15:0,
from /usr/include/boost/algorithm/string.hpp:22,
from test.cpp:1:
/usr/include/boost/algorithm/string/iter_find.hpp: In function 'SequenceSequenceT& boost::algorithm::iter_split(SequenceSequenceT&, RangeT&, FinderT) [with SequenceSequenceT = std::vector<std::basic_string<char> >, RangeT = std::basic_string<char>, FinderT = boost::algorithm::detail::first_finderF<const char*, boost::algorithm::is_equal>]':
test.cpp:15:47: instantiated from here
/usr/include/boost/algorithm/string/iter_find.hpp:154:51: error: call of overloaded 'end(std::basic_string<char>&)' is ambiguous
/usr/include/boost/algorithm/string/iter_find.hpp:154:51: note: candidates are:
/usr/include/boost/range/end.hpp:145:56: note: typename boost::range_iterator<typename boost::remove_const<T>::type>::type boost::end(T&) [with T = std::basic_string<char>, typename boost::range_iterator<typename boost::remove_const<T>::type>::type = __gnu_cxx::__normal_iterator<char*, std::basic_string<char> >]
/usr/include/boost/range/end.hpp:156:61: note: typename boost::range_const_iterator<C>::type boost::end(const T&) [with T = std::basic_string<char>, typename boost::range_const_iterator<C>::type = __gnu_cxx::__normal_iterator<const char*, std::basic_string<char> >]
/usr/lib/gcc/i686-linux-gnu/4.6.2/../../../../include/c++/4.6.2/bits/range_access.h:78:5: note: decltype (__cont.end()) std::end(const _Container&) [with _Container = std::basic_string<char>, decltype (__cont.end()) = __gnu_cxx::__normal_iterator<const char*, std::basic_string<char> >]
/usr/lib/gcc/i686-linux-gnu/4.6.2/../../../../include/c++/4.6.2/bits/range_access.h:68:5: note: decltype (__cont.end()) std::end(_Container&) [with _Container = std::basic_string<char>, decltype (__cont.end()) = __gnu_cxx::__normal_iterator<char*, std::basic_string<char> >]
test.cpp:15:47: instantiated from here
/usr/include/boost/algorithm/string/iter_find.hpp:162:39: error: call of overloaded 'begin(std::basic_string<char>&)' is ambiguous
/usr/include/boost/algorithm/string/iter_find.hpp:162:39: note: candidates are:
/usr/include/boost/range/begin.hpp:146:64: note: typename boost::range_iterator<typename boost::remove_const<T>::type>::type boost::begin(T&) [with T = std::basic_string<char>, typename boost::range_iterator<typename boost::remove_const<T>::type>::type = __gnu_cxx::__normal_iterator<char*, std::basic_string<char> >]
/usr/include/boost/range/begin.hpp:157:61: note: typename boost::range_const_iterator<C>::type boost::begin(const T&) [with T = std::basic_string<char>, typename boost::range_const_iterator<C>::type = __gnu_cxx::__normal_iterator<const char*, std::basic_string<char> >]
/usr/lib/gcc/i686-linux-gnu/4.6.2/../../../../include/c++/4.6.2/bits/range_access.h:58:5: note: decltype (__cont.begin()) std::begin(const _Container&) [with _Container = std::basic_string<char>, decltype (__cont.begin()) = __gnu_cxx::__normal_iterator<const char*, std::basic_string<char> >]
/usr/lib/gcc/i686-linux-gnu/4.6.2/../../../../include/c++/4.6.2/bits/range_access.h:48:5: note: decltype (__cont.begin()) std::begin(_Container&) [with _Container = std::basic_string<char>, decltype (__cont.begin()) = __gnu_cxx::__normal_iterator<char*, std::basic_string<char> >]
Возможно, это ошибкав GCC?Или я могу что-то сделать с кодом, чтобы это исправить?