Boost logo

Boost Users :

Subject: [Boost-users] [mpl] Documentation suggestion
From: Jeremiah Willcock (jewillco_at_[hidden])
Date: 2012-06-19 16:06:23


I have noticed that several MPL algorithms do not work when applied to
views unless an output iterator (inserter) is passed in explicitly. The
error messages when you hit one of those cases are very non-obvious,
however. It might be nice to have something in the documentation that
talks about this issue and the workarounds for it. Here is an example of
something that breaks:

#include <boost/mpl/vector_c.hpp>
#include <boost/mpl/joint_view.hpp>
#include <boost/mpl/sort.hpp>
#include <boost/mpl/print.hpp>

typedef boost::mpl::vector_c<int, 2, 0> va;
typedef boost::mpl::vector_c<int, 1, 3, -1, 5> vb;
typedef boost::mpl::joint_view<va, vb> vc;
typedef boost::mpl::sort<vc>::type vd;

The first important part of the error message with GCC 4.7.0 in C++11 mode
is:

.../boost-svn/boost/mpl/clear.hpp: In instantiation of ¡struct boost::mpl::clear<boost::mpl::joint_view<boost::mpl::vector_c<int, 2l, 0l>, boost::mpl::vector_c<int, 1l, 3l, -1l, 5l> > >¢:
.../boost-svn/boost/mpl/sort.hpp:23:1: required from ¡struct boost::mpl::sort<boost::mpl::joint_view<boost::mpl::vector_c<int, 2l, 0l>, boost::mpl::vector_c<int, 1l, 3l, -1l, 5l> > >¢
mpl_test.cpp:9:29: required from here
.../boost-svn/boost/mpl/clear.hpp:28:8: error: invalid use of incomplete type ¡struct boost::mpl::clear_impl<boost::mpl::aux::joint_view_tag>::apply<boost::mpl::joint_view<boost::mpl::vector_c<int, 2l, 0l>, boost::mpl::vector_c<int, 1l, 3l, -1l, 5l> > >¢

which seems to indicate that the default inserter needs a "real" container
as input to the algorithm in order to know what container to use for the
result. Since this limitation is probably unavoidable, some kind of note
in the documentation might be useful. Thanks.

-- Jeremiah Willcock


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net