vendredi 31 août 2018

error: call of overloaded distance is ambiguous

I have a bit of code (which I didn't write, but am trying to compile) -- iostream_combo.cc--, and doing so gives me the following error:

./moses/moses/comboreduct/combo/iostream_combo.cc: In function ‘std::__cxx11::string opencog::combo::l2ph(const string&, const std::vector >&)’: ./moses/moses/comboreduct/combo/iostream_combo.cc:543:64: error: call of overloaded ‘distance(std::vector

::const_iterator, __gnu_cxx::__normal_iterator*, std::vector > >&)’ is ambiguous arity_t idx = distance(labels.begin(), found_it) + 1; ^ In file included from /usr/include/c++/8/bits/stl_algobase.h:66, from /usr/include/c++/8/bits/char_traits.h:39, from /usr/include/c++/8/ios:40, from /usr/include/c++/8/ostream:38, from /usr/include/c++/8/iostream:39, from ./moses/moses/comboreduct/combo/iostream_combo.h:28, from ./moses/moses/comboreduct/combo/iostream_combo.cc:24: /usr/include/c++/8/bits/stl_iterator_base_funcs.h:138:5: note: candidate: ‘typename std::iterator_traits<_Iterator>::difference_type std::distance(_InputIterator, _InputIterator) [with _InputIterator = __gnu_cxx::__normal_iterator*, std::vector > >; typename std::iterator_traits<_Iterator>::difference_type = long int]’ distance(_InputIterator __first, _InputIterator __last) ^~~~~~~~ In file included from /usr/local/include/boost/range/distance.hpp:18, from /usr/local/include/boost/range/functions.hpp:21, from /usr/local/include/boost/range/iterator_range_core.hpp:38, from /usr/local/include/boost/lexical_cast.hpp:30, from ./moses/moses/comboreduct/combo/iostream_combo.h:30, from ./moses/moses/comboreduct/combo/iostream_combo.cc:24: /usr/local/include/boost/iterator/distance.hpp:49:9: note: candidate: ‘constexpr typename boost::iterators::iterator_difference::type boost::iterators::distance_adl_barrier::distance(SinglePassIterator, SinglePassIterator) [with SinglePassIterator = __gnu_cxx::__normal_iterator*, std::vector > >; typename boost::iterators::iterator_difference::type = long int]’ distance(SinglePassIterator first, SinglePassIterator last) ^~~~~~~~

I'm using Ubuntu 16.04 x64, Boost 1.68 and gcc 8.2.

I understand C++ enough (I think) that I can see that the call to std::distance is overloaded. What I don't see is the way to disambiguate it, although I guess it must include some re-writing of found_it or some explicit castings instead of auto.

Aucun commentaire:

Enregistrer un commentaire