|
Boost Users : |
From: Martin Apel (martin.apel_at_[hidden])
Date: 2008-06-19 08:07:06
Hi all,
I stumbled across something very strange related to boost::mpl::for_each
and numbered vectors and sets (as opposed to the variadic forms). The
program below contains a typelist with 21 (i.e. more than
BOOST_MPL_LIMIT_SET_SIZE) classes. This typelist is converted to a
typelist containing pointers to those classes. Finally the main program
calls for_each with that typelist to print the names of the types. This
works without problems on Linux and Windows. But now:
If you remove the include "boost/mpl/vector/vector30.hpp" everything
still compiles fine without warnings under both operating systems. On
Linux everything continues to work, whereas under Windows nothing is
printed anymore. for_each does not loop through the typelist for an
unknown reason. Everything works again, when reducing the number of
classes to 20 (and adjusting the include to set20.hpp).
From my understanding BOOST_MPL_LIMIT_SET_SIZE and its brothers and
sisters should not have any impact on numbered sequences, only on
variadic ones. But still it looks as if something very strange is
happening here.
Any comments are welcome,
Martin
#include <iostream>
#include "boost/mpl/vector/vector30.hpp"
#include "boost/mpl/set/set30.hpp"
#include "boost/mpl/for_each.hpp"
#include "boost/mpl/transform.hpp"
#include "boost/mpl/inserter.hpp"
#include "boost/mpl/vector.hpp"
#include "boost/type_traits/add_pointer.hpp"
class C1;
class C2;
class C3;
class C4;
class C5;
class C6;
class C7;
class C8;
class C9;
class C10;
class C11;
class C12;
class C13;
class C14;
class C15;
class C16;
class C17;
class C18;
class C19;
class C20;
class C21;
typedef boost::mpl::set21<C1,
C2,
C3,
C4,
C5,
C6,
C7,
C8,
C9,
C10,
C11,
C12,
C13,
C14,
C15,
C16,
C17,
C18,
C19,
C20,
C21
> ElementClasses;
typedef
boost::mpl::transform<ElementClasses,boost::add_pointer<boost::mpl::_1>,
boost::mpl::inserter<boost::mpl::vector0<>,
boost::mpl::push_back<boost::mpl::_1, boost::mpl::_2> > >::type
ElementClassesAsPointer;
class Test
{
public:
Test(void)
{
boost::mpl::for_each<ElementClassesAsPointer> (*this);
}
template<class T>
void operator() (T x)
{
std::cout << "Operator() called for type " << typeid(T).name()
<< std::endl;
}
};
int main(void)
{
Test test;
}
____________
Virus checked by G DATA AntiVirus
Version: AVKA 18.302 from 18.06.2008
Virus news: www.antiviruslab.com
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