
Hi, This code: #include <boost/mpl/vector.hpp> #include <boost/mpl/pop_front.hpp> #include <boost/mpl/assert.hpp> #include <boost/mpl/equal.hpp> using namespace boost; // Doc says: pop_front returns a vector typedef mpl::pop_front< mpl::vector<bool,char,int> >::type v; // Doc says: vectors have a type member equal to itself BOOST_MPL_ASSERT(( mpl::equal< v, v::type > )); fails to compile with GCC ( v::type is mpl::vector3<bool,char,int> ) and compiles fine with other compilers. Examples for false conclusions that could be easily drawn from the current documentation: "Oh great - I do not need mpl::identity when using v with mpl::eval_if" "Let's inherit from 'v::type' so I can save the '::type' later" "::type always gives the numbered form of my current sequence so I can use it with partial specialization" I got trapped by this in two different places (and I still hope not to be surpassingly stupid ;-). Shouldn't this behaviour be documented in some way ? Regards, Tobias

Tobias Schwinger <tschwinger@neoscientists.org> writes:
Hi,
This code:
#include <boost/mpl/vector.hpp> #include <boost/mpl/pop_front.hpp> #include <boost/mpl/assert.hpp> #include <boost/mpl/equal.hpp>
using namespace boost;
// Doc says: pop_front returns a vector typedef mpl::pop_front< mpl::vector<bool,char,int> >::type v;
// Doc says: vectors have a type member equal to itself BOOST_MPL_ASSERT(( mpl::equal< v, v::type > ));
fails to compile with GCC ( v::type is mpl::vector3<bool,char,int> )
That's a bug. If that's truly happening, the documentation is correct and the implementation is wrong.
and compiles fine with other compilers.
Examples for false conclusions that could be easily drawn from the current documentation:
"Oh great - I do not need mpl::identity when using v with mpl::eval_if"
"Let's inherit from 'v::type' so I can save the '::type' later"
"::type always gives the numbered form of my current sequence so I can use it with partial specialization"
I got trapped by this in two different places (and I still hope not to be surpassingly stupid ;-). Shouldn't this behaviour be documented in some way ?
No, it should be fixed. mpl::pop_front< mpl::vector<bool,char,int> >::type::type should always be a sequence of length 2 containing (char, int). -- Dave Abrahams Boost Consulting www.boost-consulting.com

David Abrahams wrote:
Tobias Schwinger <tschwinger@neoscientists.org> writes:
Hi,
This code:
#include <boost/mpl/vector.hpp> #include <boost/mpl/pop_front.hpp> #include <boost/mpl/assert.hpp> #include <boost/mpl/equal.hpp>
using namespace boost;
// Doc says: pop_front returns a vector typedef mpl::pop_front< mpl::vector<bool,char,int> >::type v;
// Doc says: vectors have a type member equal to itself BOOST_MPL_ASSERT(( mpl::equal< v, v::type > ));
fails to compile with GCC ( v::type is mpl::vector3<bool,char,int> )
That's a bug. If that's truly happening, the documentation is correct and the implementation is wrong.
Here's the output of the above program in case you don't have a gcc handy to convince yourself: tmp.cpp:12: error: conversion from `mpl_::failed************boost::mpl::equal<v, boost::mpl::vector3<bool, char, int>, boost::is_same<mpl_::_, mpl_::_> >::************' to non-scalar type `mpl_::assert< false>' requested tmp.cpp:12: error: enumerator value for `mpl_assertion_in_line_14' not integer constant
No, it should be fixed.
mpl::pop_front< mpl::vector<bool,char,int> >::type::type
should always be a sequence of length 2 containing (char, int).
Problems resulting from this are for sure vicious to track... Note that 'pop_front' is arbitrary - it applies to all front/back mutators. Regards, Tobias
participants (2)
-
David Abrahams
-
Tobias Schwinger