Joaquín M López Muñoz wrote:
#include
#include int main() { typedef boost::mpl::list<> type0; typedef boost::mpl::push_back
::type type1; typedef boost::mpl::push_back ::type type2; return 0; }
This fails in MSVC 6.5 and gcc 3.2. The error seems to indicate that push_back does not provide a type named 'type'. If I replace push_back with push_front, eveything works wonderfully. Am I doing any gross error, is the documentation wrong, ideas, clues? Thanx in advance.
Hi Joaquín, The code above doesn't compile because 'list', although being an extensible sequence, does not support O(1) insertion/removal of elements at the end - only at the beginning. Please see http://www.boost.org/libs/mpl/doc/ref/Reference/list.html. Having said that, I should also mention that there is a mismatch between the docs and the code specifically related to 'push_back' - namely, if in the above example you replace 'list' with 'vector', it still won't compile, contrary to what is said on the vector's reference page. This is a known issue. Basically, currently 'vector's characteristics _as an extensible sequence_ are the same as these of the 'list'; of course, it's still a random access sequence - the docs don't lie here :). It's going to be fixed in the next release; the new 'vector' implementation is going to provide constant time insertion at both ends, giving you both 'push_front' _and_ 'push_back'. Meanwhile, please bear with us :). HTH, Aleksey