Boost Geometry: assertion_failed error C++ - c++

I have the following header file in order to use boost geometry types:
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/polygon.hpp>
#include <boost/geometry/multi/geometries/multi_polygon.hpp>
#include <boost/geometry/geometries/register/point.hpp>
using namespace boost::geometry;
using namespace detail::assign;
typedef model::d2::point_xy<double> point_xy;
typedef model::polygon<point_xy> polygon;
typedef model::multi_polygon<polygon> multi_polygon;
typedef model::box<point_xy> box;
When compiling a file that attempts to use these types, I get a massive compiler error:
In file included from src/geometry.cpp:11:
In file included from src/../include/geometry.hpp:9:
In file included from /usr/local/include/boost/geometry.hpp:17:
In file included from /usr/local/include/boost/geometry/geometry.hpp:26:
In file included from /usr/local/include/boost/geometry/core/coordinate_dimension.hpp:23:
/usr/local/include/boost/geometry/core/point_type.hpp:45:5: error: no matching function for call to 'assertion_failed'
BOOST_MPL_ASSERT_MSG
^~~~~~~~~~~~~~~~~~~~
/usr/local/include/boost/mpl/assert.hpp:454:51: note: expanded from macro 'BOOST_MPL_ASSERT_MSG'
# define BOOST_MPL_ASSERT_MSG( c, msg, types_ ) \
^
/usr/local/include/boost/mpl/assert.hpp:440:9: note: expanded from macro '\
BOOST_MPL_ASSERT_MSG_IMPL'
boost::mpl::assertion_failed<(c)>( BOOST_PP_CAT(mpl_assert_arg,counter)::assert_arg() ) \
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/boost/mpl/assert.hpp:60:58: note: expanded from macro '\
BOOST_MPL_AUX_ASSERT_CONSTANT'
# define BOOST_MPL_AUX_ASSERT_CONSTANT(T, expr) enum { expr }
^~~~
/usr/local/include/boost/geometry/core/point_type.hpp:65:30: note: in instantiation of template class
'boost::geometry::traits::point_type<std::__1::vector<float, std::__1::allocator<float> > >' requested here
typename traits::point_type<Geometry>::type
^
/usr/local/include/boost/geometry/core/coordinate_type.hpp:58:22: note: in instantiation of template class 'boost::geometry::core_dispatch::point_type<void,
std::__1::vector<float, std::__1::allocator<float> > >' requested here
typedef typename point_type<GeometryTag, Geometry>::type point_type;
^
/usr/local/include/boost/geometry/core/coordinate_type.hpp:88:37: note: in instantiation of template class 'boost::geometry::core_dispatch::coordinate_type<void,
std::__1::vector<float, std::__1::allocator<float> > >' requested here
typedef typename core_dispatch::coordinate_type
^
/usr/local/include/boost/geometry/core/access.hpp:269:17: note: in instantiation of template class 'boost::geometry::coordinate_type<std::__1::vector<float,
std::__1::allocator<float> > >' requested here
inline typename coordinate_type<Geometry>::type get(Geometry const& geometry
^
/usr/local/include/boost/geometry/algorithms/detail/convert_point_to_point.hpp:42:74: note: while substituting deduced template arguments into function template
'get' [with Dimension = 0, Geometry = std::__1::vector<float, std::__1::allocator<float> >]
set<Dimension>(destination, boost::numeric_cast<coordinate_type>(get<Dimension>(source)));
^
/usr/local/include/boost/geometry/algorithms/detail/convert_point_to_point.hpp:58:76: note: (skipping 3 contexts in backtrace; use -ftemplate-backtrace-limit=0
to see all)
point_to_point<Source, Destination, 0, dimension<Destination>::value>::apply(source, destination);
^
/usr/local/include/boost/geometry/algorithms/append.hpp:129:45: note: in instantiation of member function
'boost::geometry::detail::append::append_range<boost::geometry::model::ring<boost::geometry::model::d2::point_xy<double, boost::geometry::cs::cartesian>,
true, true, vector, allocator>, std::__1::vector<std::__1::vector<float, std::__1::allocator<float> >, std::__1::allocator<std::__1::vector<float,
std::__1::allocator<float> > > > >::apply' requested here
append_range<ring_type, Range>::apply(
^
/usr/local/include/boost/geometry/algorithms/append.hpp:296:51: note: in instantiation of member function
'boost::geometry::detail::append::range_to_polygon<boost::geometry::model::polygon<boost::geometry::model::d2::point_xy<double,
boost::geometry::cs::cartesian>, true, true, std::vector, std::vector, std::allocator, std::allocator>, std::__1::vector<std::__1::vector<float,
std::__1::allocator<float> >, std::__1::allocator<std::__1::vector<float, std::__1::allocator<float> > > > >::apply' requested here
dispatch::append<Geometry, RangeOrPoint>::apply(geometry,
^
/usr/local/include/boost/geometry/algorithms/append.hpp:371:22: note: in instantiation of function template specialization
'boost::geometry::resolve_variant::append<boost::geometry::model::polygon<boost::geometry::model::d2::point_xy<double, boost::geometry::cs::cartesian>,
true, true, std::vector, std::vector, std::allocator, std::allocator> >::apply<std::__1::vector<std::__1::vector<float, std::__1::allocator<float> >,
std::__1::allocator<std::__1::vector<float, std::__1::allocator<float> > > > >' requested here
::apply(geometry, range_or_point, ring_index, multi_index);
^
/usr/local/include/boost/geometry/algorithms/assign.hpp:75:15: note: in instantiation of function template specialization
'boost::geometry::append<boost::geometry::model::polygon<boost::geometry::model::d2::point_xy<double, boost::geometry::cs::cartesian>, true, true,
std::vector, std::vector, std::allocator, std::allocator>, std::__1::vector<std::__1::vector<float, std::__1::allocator<float> >,
std::__1::allocator<std::__1::vector<float, std::__1::allocator<float> > > > >' requested here
geometry::append(geometry, range, -1, 0);
^
src/geometry.cpp:213:5: note: in instantiation of function template specialization
'boost::geometry::assign_points<boost::geometry::model::polygon<boost::geometry::model::d2::point_xy<double, boost::geometry::cs::cartesian>, true, true,
std::vector, std::vector, std::allocator, std::allocator>, std::__1::vector<std::__1::vector<float, std::__1::allocator<float> >,
std::__1::allocator<std::__1::vector<float, std::__1::allocator<float> > > > >' requested here
assign_points(poly, shape.border);
^
/usr/local/include/boost/mpl/assert.hpp:83:5: note: candidate function not viable: no known conversion from 'boost::mpl::failed
************(boost::geometry::traits::point_type<std::__1::vector<float, std::__1::allocator<float> >
>::NOT_IMPLEMENTED_FOR_THIS_POINT_TYPE::************)(types<std::__1::vector<float, std::__1::allocator<float> > >)' to 'typename assert<false>::type'
(aka 'mpl_::assert<false>') for 1st argument
int assertion_failed( typename assert<C>::type );
^
In file included from src/geometry.cpp:11:
In file included from src/../include/geometry.hpp:9:
In file included from /usr/local/include/boost/geometry.hpp:17:
In file included from /usr/local/include/boost/geometry/geometry.hpp:28:
/usr/local/include/boost/geometry/core/coordinate_type.hpp:43:5: error: no matching function for call to 'assertion_failed'
BOOST_MPL_ASSERT_MSG
^~~~~~~~~~~~~~~~~~~~
/usr/local/include/boost/mpl/assert.hpp:454:51: note: expanded from macro 'BOOST_MPL_ASSERT_MSG'
# define BOOST_MPL_ASSERT_MSG( c, msg, types_ ) \
I have seen this post in which they did not register tuples - however, I am not using tuples or any special kind of point - I am just attempting to use the built in geometry types. Why is this error still occurring?

As you can see, the code posted is not a problem per se: Live On Coliru.
So,there must be something else interfering. I have three hunches:
It's somewhere else in your code that you didn't post. The cause of the error is in ../src/geometry.cpp (not Boost library):
assign_points(poly, shape.border);
That gives you good ideas on how to reduce to a MCVE.
You have preprocessor issues. Try pre-processing your sources and see whether any of the code appearing in the error messages looks suspect.
A classical example of this would be if some other included header defines tokens like #define min(a,b) ... or other commonly used words.
Side note: this is about code-hygiene. A related note is the appearance of using namespace in your shown code snippet. This just begs namespace collisions or unintended effects.
Slightly related: the source of the interference could have to do with pre-compiled headers. Try disabling those or making sure you know what is in the PCH header (especially on MSVC (commonly using stdafx.h) precompiled headers have some potentially surprising effects)
UPDATE
I think I spotted it: the offending code at src/geometry.cpp:213:5 calls:
assign_points(poly, shape.border);
With the types: poly is
boost::geometry::model::polygon<boost::geometry::model::d2::point_xy<double, boost::geometry::cs::cartesian>, true, true, std::vector, std::vector, std::allocator, std::allocator>,
That's the polygon typedef you show above. But shape.border is:
std::__1::vector<std::__1::vector<float, std::__1::allocator<float>>, std::__1::allocator<std::__1::vector<float, std::__1::allocator<float>>>>>
That's just vector<std::vector<float> >. That's not a supported Geometry.

Related

What is behaviour of cpp sort function, by using default overloaded greater function for vector<vector<int>>

Difference between sort(begin(ans), end(ans)) vs sort(begin(ans), end(ans), std::greater<std::vector<std::vector<int> > >())
as sort(begin(ans), end(ans)) works perfectly as expected where as specifing the greater doesn't works.
vector<int> S = {12,13, 34, 9,10};
vector<vector<int> >ans;
vector<int> currSet;
subset(0, S, currSet, ans);
sort(begin(ans), end(ans), std::greater<std::vector<std::vector<int> > >());
cout << ans.size();
}
give error
In file included from subset.cpp:1:
In file included from /usr/local/include/bits/stdc++.h:52:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/ccomplex:21:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/complex:247:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/sstream:174:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/ostream:138:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/ios:216:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/__locale:15:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/string:505:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/string_view:176:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/__string:57:
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/algorithm:3832:17: error: no
matching function for call to object of type
'std::__1::greater<std::__1::vector<std::__1::vector<int, std::__1::allocator<int> >,
std::__1::allocator<std::__1::vector<int, std::__1::allocator<int> > > > >'
if (__comp(*--__last, *__first))
^~~~~~
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/algorithm:4018:5: note: in
instantiation of function template specialization
'std::__1::__sort<std::__1::greater<std::__1::vector<std::__1::vector<int,
std::__1::allocator<int> >, std::__1::allocator<std::__1::vector<int,
std::__1::allocator<int> > > > > &, std::__1::vector<int, std::__1::allocator<int> >
*>' requested here
__sort<_Comp_ref>(__first, __last, __comp);
^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/algorithm:4052:12: note: in
instantiation of function template specialization
'std::__1::sort<std::__1::vector<int, std::__1::allocator<int> > *,
std::__1::greater<std::__1::vector<std::__1::vector<int, std::__1::allocator<int> >,
std::__1::allocator<std::__1::vector<int, std::__1::allocator<int> > > > > &>'
requested here
_VSTD::sort<_Tp*, _Comp_ref>(__first.base(), __last.base(), __comp);
^
subset.cpp:33:3: note: in instantiation of function template specialization
'std::__1::sort<std::__1::vector<int, std::__1::allocator<int> >,
std::__1::greater<std::__1::vector<std::__1::vector<int, std::__1::allocator<int> >,
std::__1::allocator<std::__1::vector<int, std::__1::allocator<int> > > > > >'
requested here
sort(all(ans), greater<vector<vector<int> > >());
^
std::greater<std::vector<std::vector<int> > > is for comparing objects of type std::vector<std::vector<int> >. But the vector ans does not contain objects of that type. It contains objects of type std::vector<int>. Thus, the comparator that you need is std::greater<std::vector<int>>. Or, you could simply use std::greater<> which is simpler to read, write and less likely to result in a bug.
The template prameter for std::greater needs to be the element type that the iterators point to. Since the iterator for of std::vector<std::vector<int>> has a value_type of std::vector<int> (that's the type of the of the elements in ans) that is what you need. That gives you
sort(begin(ans), end(ans), std::greater<std::vector<int> >());
as what you need.
Also note that a space is no longer required for the closing > in a template parameter list. You can use
sort(begin(ans), end(ans), std::greater<std::vector<int>>());
and that will compile in a C++11+ compliant compiler.

Seqan mini-bowtie example not compiling

I try to copy the example of mini-bowtie from the Seqan Web site.
Note that the example comes from version 1.4.2, not the current one.
When I compile, I have an error.
The minimal reproducible example is:
#include <seqan/index.h>
#include <seqan/store.h>
using namespace seqan;
int main()
{
typedef Index<StringSet<Dna5String>, FMIndex<> > TIndex;
typedef Iterator<TIndex, TopDown<ParentLinks<> > >::Type TIter;
FragmentStore<> fragStore;
StringSet<Dna5String> text;
TIndex fmIndex(text);
TIter it(fmIndex);
it = TIter(fmIndex); // This does not work
return 0;
}
The compiling error is quite long.
It starts with:
In file included from test.cpp:1:
In file included from /usr/include/seqan/index.h:172:
/usr/include/seqan/index/index_fm_stree.h:469:16: error: no matching constructor for initialization of 'TVertexDescriptor' (aka 'VertexFM<unsigned long, seqan::SimpleType<unsigned char, seqan::Dna5_> >')
return TVertexDescriptor(back(it.history).range, back(it.history).repLen, back(it.history).lastChar);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/seqan/index/index_esa_stree.h:245:27: note: in instantiation of function template specialization 'seqan::nodeUp<seqan::StringSet<seqan::String<seqan::SimpleType<unsigned char, seqan::Dna5_>,
seqan::Alloc<void> >, seqan::Owner<seqan::Tag<seqan::Default_> > >, void, seqan::FMIndexConfig<void, unsigned long, 1, 1>, seqan::Preorder>' requested here
_parentDesc = nodeUp(_origin);
^
/usr/include/seqan/index/index_esa_stree.h:366:29: note: in instantiation of function template specialization 'seqan::Iter<seqan::Index<seqan::StringSet<seqan::String<seqan::SimpleType<unsigned char,
seqan::Dna5_>, seqan::Alloc<void> >, seqan::Owner<seqan::Tag<seqan::Default_> > >, seqan::FMIndex<void, seqan::FMIndexConfig<void, unsigned long, 1, 1> > >, seqan::VSTree<seqan::TopDown<seqan::Preorder> >
>::operator=<seqan::ParentLinks<seqan::Preorder> >' requested here
*(TBase*)(this) = _origin;
^
test.cpp:17:8: note: in instantiation of member function 'seqan::Iter<seqan::Index<seqan::StringSet<seqan::String<seqan::SimpleType<unsigned char, seqan::Dna5_>, seqan::Alloc<void> >,
seqan::Owner<seqan::Tag<seqan::Default_> > >, seqan::FMIndex<void, seqan::FMIndexConfig<void, unsigned long, 1, 1> > >, seqan::VSTree<seqan::TopDown<seqan::ParentLinks<seqan::Preorder> > > >::operator='
requested here
it = TIter(fmIndex);
^
It seems that the API has slightly changed, but I cannot exactly put the finger on it.
I compile with:
clang++ -Wall -Wextra -Weffc++ -O2 -o testSeqan test.cpp -lrt
with clang++ 6.0.0-1ubuntu2 x86_64-pc-linux-gnu, but g++ Ubuntu 7.3.0-16ubuntu3 gives similar (albeit less readable) results, and Seqan version 2.3.2.
What should I change?

Why does Boost Variant use the template constructor instead of the move constructor for boost::beast::websocket::stream?

I am trying to wrap boost::beast::websocket::stream<T> (for 2 specific T) in a boost::variant to allow treating TLS ([T = boost::asio::ssl::stream<boost::asio::ip::tcp::socket>]) and non-TLS ([T = boost::asio::ip::tcp::socket]) websockets the same. I am stuck at a compilation failure.
The simplest failing example that I can come up with is:
#include <boost/asio/ssl.hpp>
#include <boost/beast/core.hpp>
#include <boost/beast/websocket.hpp>
#include <boost/variant.hpp>
using tcp = boost::asio::ip::tcp;
namespace ws = boost::beast::websocket;
namespace ssl = boost::asio::ssl;
using base_ws = boost::variant<
ws::stream<tcp::socket>, ws::stream<ssl::stream<tcp::socket>>>;
class test
{
public:
static void init( tcp::socket && socket )
{
ssl::context ctx{ ssl::context::tlsv12_server };
ws::stream<ssl::stream<tcp::socket>> s{ std::move( socket ), ctx };
base_ws{ std::move( s ) };
}
};
int main()
{}
Which fails to compile with error:
In file included from /server/src/ws_server.cpp:9:
In file included from /include/boost/beast/websocket.hpp:18:
In file included from /include/boost/beast/websocket/stream.hpp:3455:
/include/boost/beast/websocket/impl/stream.ipp:47:7: error: no matching constructor for initialization of 'boost::asio::ssl::stream<boost::asio::basic_stream_socket<boost::asio::ip::tcp> >'
: stream_(std::forward<Args>(args)...)
^ ~~~~~~~~~~~~~~~~~~~~~~~~
/include/boost/variant/detail/initializer.hpp:122:27: note: in instantiation of function template specialization 'boost::beast::websocket::stream<boost::asio::ssl::stream<boost::asio::basic_stream_socket<boost::asio::ip::tcp> > >::stream<boost::beast::websocket::stream<boost::asio::ssl::stream<boost::asio::basic_stream_socket<boost::asio::ip::tcp> > > >' requested here
new(dest) value_T( boost::detail::variant::move(operand) );
^
/include/boost/variant/variant.hpp:1687:28: note: in instantiation of member function 'boost::detail::variant::make_initializer_node::apply<boost::mpl::pair<boost::detail::variant::make_initializer_node::apply<boost::mpl::pair<boost::detail::variant::initializer_root, mpl_::int_<0> >, boost::mpl::l_iter<boost::mpl::list2<boost::beast::websocket::stream<boost::asio::basic_stream_socket<boost::asio::ip::tcp> >, boost::beast::websocket::stream<boost::asio::ssl::stream<boost::asio::basic_stream_socket<boost::asio::ip::tcp> > > > > >::initializer_node, mpl_::int_<1> >, boost::mpl::l_iter<boost::mpl::list1<boost::beast::websocket::stream<boost::asio::ssl::stream<boost::asio::basic_stream_socket<boost::asio::ip::tcp> > > > > >::initializer_node::initialize' requested here
initializer::initialize(
^
/include/boost/variant/variant.hpp:1858:9: note: in instantiation of function template specialization 'boost::variant<boost::beast::websocket::stream<boost::asio::basic_stream_socket<boost::asio::ip::tcp> >, boost::beast::websocket::stream<boost::asio::ssl::stream<boost::asio::basic_stream_socket<boost::asio::ip::tcp> > > >::convert_construct<boost::beast::websocket::stream<boost::asio::ssl::stream<boost::asio::basic_stream_socket<boost::asio::ip::tcp> > > >' requested here
convert_construct( detail::variant::move(operand), 1L);
^
/server/src/ws_server.cpp:372:20: note: in instantiation of function template specialization 'boost::variant<boost::beast::websocket::stream<boost::asio::basic_stream_socket<boost::asio::ip::tcp> >, boost::beast::websocket::stream<boost::asio::ssl::stream<boost::asio::basic_stream_socket<boost::asio::ip::tcp> > > >::variant<boost::beast::websocket::stream<boost::asio::ssl::stream<boost::asio::basic_stream_socket<boost::asio::ip::tcp> > > >' requested here
return base_ws( std::move( s ) );
^
/include/boost/asio/ssl/stream.hpp:64:7: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'boost::beast::websocket::stream<boost::asio::ssl::stream<boost::asio::basic_stream_socket<boost::asio::ip::tcp> > >' to 'const boost::asio::ssl::stream<boost::asio::basic_stream_socket<boost::asio::ip::tcp> >' for 1st argument
class stream :
^
/include/boost/asio/ssl/stream.hpp:98:3: note: candidate constructor template not viable: requires 2 arguments, but 1 was provided
stream(Arg&& arg, context& ctx)
^
I would provide godbolt however it times out, and coliru does not provide openssl which is required for boost/asio/ssl.hpp.
Per here, boost::variant should accept T && and use it to instantiate T internally.
Per here, boost::beast::websocket::stream does have a move constructor.
The move constructor is more specific, so why is the compiler selecting the variadic constructor (stream<...>) as indicated in the first note?
boost::beast::websocket::stream<
boost::asio::ssl::stream<
boost::asio::basic_stream_socket<boost::asio::ip::tcp>
>
>::stream<
boost::beast::websocket::stream<
boost::asio::ssl::stream<
boost::asio::basic_stream_socket<boost::asio::ip::tcp>
>
>
>
I am using Boost 1.66.0 and Clang 7.
The critical information I overlooked was in the description of boost::beast::websocket::stream::stream(stream&&):
If NextLayer is move constructible, this function will move-construct a new stream from the existing stream.
It turns out that boost::asio::ssl::stream is not move constructible, so the defaulted move constructor of stream was not generated. There is an open issue to make ssl::stream move constructible in chriskohlhoff/asio#124 which references the boost bugtracker.
A solution to the problem then is to use a move constructible implementation of ssl::stream, like the one provided in the Beast examples here, which looks like it may be available at boost/beast/experimental/core/ssl_stream.hpp in a later version of Beast (not in 1.67.0).
The advanced-server-flex example shows how to build a server with code that handles both SSL and plain websocket sessions, without the need to resort to a variant: https://github.com/boostorg/beast/blob/c2ecba968c06a22a61c67b8887f5b477bb32a99a/example/advanced/server-flex/advanced_server_flex.cpp#L227

vector<string> and find: template argument deduction/substitution failed?

I'm not sure what I'm doing wrong here:
vector<string> names;
...
string lh = "localhost";
vector<string>::iterator it = std::find(names.begin(), names.end(), lh);
if(it != names.end())
names.push_back(lh);
The line with find results in:
../source/ac-pki-4.cpp: In function ‘std::vector<std::basic_string<char> > GetServerAltNames()’:
../source/ac-pki-4.cpp:757:76: error: no matching function for call to ‘find(std::vector<std::basic_string<char> >::iterator, std::vector<std::basic_string<char> >::iterator, std::basic_string<char>&)’
../source/ac-pki-4.cpp:757:76: note: candidate is:
In file included from /usr/include/c++/4.7/bits/locale_facets.h:50:0,
from /usr/include/c++/4.7/bits/basic_ios.h:39,
from /usr/include/c++/4.7/ios:45,
from /usr/include/c++/4.7/ostream:40,
from /usr/include/c++/4.7/iostream:40,
from /home/jwalton/ac/include/ac-common.h:33,
from ../source/ac-pki-4.cpp:1:
/usr/include/c++/4.7/bits/streambuf_iterator.h:371:5: note: template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT2, std::char_traits<_CharT> > >::__type std::find(std::istreambuf_iterator<_CharT2, std::char_traits<_CharT> >, std::istreambuf_iterator<_CharT2, std::char_traits<_CharT> >, const _CharT2&)
/usr/include/c++/4.7/bits/streambuf_iterator.h:371:5: note: template argument deduction/substitution failed:
../source/ac-pki-4.cpp:757:76: note: ‘__gnu_cxx::__normal_iterator<std::basic_string<char>*, std::vector<std::basic_string<char> > >’ is not derived from ‘std::istreambuf_iterator<_CharT2, std::char_traits<_CharT> >’
make: *** [source/ac-pki-4.o] Error 1
I also tried the following with no joy:
std::basic_string<char> lh = "localhost";
And I tried a const_iterator with no joy.
Below is a screen capture of what I am seeing under Eclipse.
Any ideas what I'm doing wrong? (And why is a istreambuf_iterator being used in this case?).
<iostream> seems to be including some headers that have an overload of std::find that is different from the one that resides in <algorithm>. In order to use the correct one, you must include <algorithm>. Uncomment the include line on this live example to see what I mean (and <iostream> too for further investigation.) See libstdc++ docs.

Are there any tools that can help me read c++ template compiling errors? [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Deciphering C++ template error messages
everytime I get this kind of template error message:
In file included from /usr/include/boost/mpl/set/aux_/iterator.hpp:19:0,
from /usr/include/boost/mpl/set/aux_/begin_end_impl.hpp:19,
from /usr/include/boost/mpl/set/set0.hpp:29,
from /usr/include/boost/parameter/aux_/set.hpp:13,
from /usr/include/boost/parameter/parameters.hpp:48,
from /usr/include/boost/accumulators/framework/accumulator_set.hpp:19,
from /usr/include/boost/accumulators/accumulators.hpp:12,
from src/SimMany.cpp:4:
/usr/include/boost/mpl/has_key.hpp: In instantiation of ‘boost::mpl::has_key<mpl_::arg<1>, mpl_::ar
g<2> >’:
/usr/include/boost/mpl/if.hpp:67:11: instantiated from ‘boost::mpl::if_<boost::mpl::has_key<mpl_:
:arg<1>, mpl_::arg<2> >, boost::mpl::identity<mpl_::arg<1> >, boost::mpl::insert<mpl_::arg<1>, boos
t::mpl::pair<mpl_::arg<2>, mpl_::arg<2> >, mpl_::na> >’
/usr/include/boost/mpl/eval_if.hpp:37:41: instantiated from ‘boost::mpl::eval_if<boost::mpl::has_
key<mpl_::arg<1>, mpl_::arg<2> >, boost::mpl::identity<mpl_::arg<1> >, boost::mpl::insert<mpl_::arg
<1>, boost::mpl::pair<mpl_::arg<2>, mpl_::arg<2> >, mpl_::na> >’
/usr/include/boost/accumulators/framework/depends_on.hpp:330:9: instantiated from ‘boost::accumul
ators::detail::insert_feature<mpl_::arg<1>, mpl_::arg<2> >’
/usr/include/boost/mpl/aux_/preprocessed/gcc/template_arity.hpp:85:5: instantiated from ‘const in
t boost::mpl::aux::template_arity_impl<boost::accumulators::detail::insert_feature<mpl_::arg<1>, mp
l_::arg<2> >, 1>::value’
/usr/include/boost/mpl/aux_/preprocessed/gcc/template_arity.hpp:93:5: instantiated from ‘const in
t boost::mpl::aux::template_arity<boost::accumulators::detail::insert_feature<mpl_::arg<1>, mpl_::a
rg<2> > >::value’
/usr/include/boost/mpl/aux_/preprocessed/gcc/template_arity.hpp:98:30: [ skipping 2 instantiation
contexts ]
/usr/include/boost/mpl/aux_/preprocessed/gcc/apply.hpp:73:1: instantiated from ‘boost::mpl::apply
2<boost::mpl::if_<boost::mpl::is_sequence<mpl_::arg<2> >, boost::accumulators::detail::insert_seque
nce<mpl_::arg<1>, mpl_::arg<2>, void>, boost::accumulators::detail::insert_feature<mpl_::arg<1>, mp
l_::arg<2> > >, boost::mpl::map0<>, boost::accumulators::tag::mean>’
/usr/include/boost/mpl/aux_/preprocessed/gcc/fold_impl.hpp:166:1: instantiated from ‘boost::mpl::
aux::fold_impl<-0x00000000000000001, boost::mpl::aux::transform_iter<boost::mpl::v_iter<boost::accu
mulators::stats<boost::accumulators::tag::mean, boost::accumulators::tag::variance(boost::accumulat
ors::lazy)>, 0l>, boost::mpl::v_iter<boost::accumulators::stats<boost::accumulators::tag::mean, boo
st::accumulators::tag::variance(boost::accumulators::lazy)>, 2l>, boost::mpl::protect<boost::mpl::b
ind1<boost::mpl::quote1<boost::accumulators::as_feature, mpl_::void_>, mpl_::arg<1> >, 0> >, boost:
:mpl::aux::transform_iter<boost::mpl::v_iter<boost::accumulators::stats<boost::accumulators::tag::m
ean, boost::accumulators::tag::variance(boost::accumulators::lazy)>, 2l>, boost::mpl::v_iter<boost:
:accumulators::stats<boost::accumulators::tag::mean, boost::accumulators::tag::variance(boost::accu
mulators::lazy)>, 2l>, boost::mpl::protect<boost::mpl::bind1<boost::mpl::quote1<boost::accumulators
::as_feature, mpl_::void_>, mpl_::arg<1> >, 0> >, boost::mpl::map0<>, boost::mpl::if_<boost::mpl::i
s_sequence<mpl_::arg<2> >, boost::accumulators::detail::insert_sequence<mpl_::arg<1>, mpl_::arg<2>,
void>, boost::accumulators::detail::insert_feature<mpl_::arg<1>, mpl_::arg<2> > > >’
/usr/include/boost/mpl/fold.hpp:39:18: instantiated from ‘boost::mpl::fold<boost::accumulators::d
etail::as_feature_list<boost::accumulators::stats<boost::accumulators::tag::mean, boost::accumulato
rs::tag::variance(boost::accumulators::lazy)>, void>, boost::mpl::map0<>, boost::mpl::if_<boost::mp
l::is_sequence<mpl_::arg<2> >, boost::accumulators::detail::insert_sequence<mpl_::arg<1>, mpl_::arg
<2>, void>, boost::accumulators::detail::insert_feature<mpl_::arg<1>, mpl_::arg<2> > > >’
/usr/include/boost/accumulators/framework/depends_on.hpp:370:13: instantiated from ‘boost::accumu
lators::detail::make_accumulator_tuple<boost::accumulators::stats<boost::accumulators::tag::mean, b
oost::accumulators::tag::variance(boost::accumulators::lazy)>, double, void>’
/usr/include/boost/accumulators/framework/accumulator_set.hpp:122:5: instantiated from ‘boost::ac
cumulators::accumulator_set<double, boost::accumulators::stats<boost::accumulators::tag::mean, boos
t::accumulators::tag::variance(boost::accumulators::lazy)> >’
src/SimMany.cpp:70:7: instantiated from here
/usr/include/boost/mpl/has_key.hpp:33:1: error: no class template named ‘apply’ in ‘struct boost::m
pl::has_key_impl<boost::mpl::non_sequence_tag>’
I get reaaaaaaally lost. I can't even visually parse where one error message starts and another ends. Are there any dev tools that can help me with this?
This gets particularly scary when I'm using boost libraries. :(
STLFilt or use different compiler. Clang has supposedly better error messages (I cannot tell for sure, I didn't used it personally)