Boost logo

Boost :

From: Aleksey Gurtovoy (agurtovoy_at_[hidden])
Date: 2003-02-23 20:14:53


Andreas Huber wrote:
> Hi Aleksey & all other metaprogramming gurus

Hi Andreas,

>
> The attached code compiles just fine with MSVC7.1 but MSVC7.0 once more
has
> its problems. This time I'm quite sure it has nothing to do with MPL,
> instead VC7.0 seems to get confused and reports the following:
>
> d:\Data\StopWatch\StopWatch.cpp(58) : error C2516:
> 'state_base_type<Derived,Context,Transitions,InnerInitial>::type' : is not
a
> legal base class
>
> According to the docs this error is reported when you try to inherit from
> built-in types like int.
> If you then remove the 3 first characters of the lines marked with // ***
> here ***, the program compiles and you can see in the debugger that the
> result returned by the metafunction state_base_type is quite a legal base
> class (see type of pWhatever).
>
> Has anyone else ever encountered similar problems with either 7.0 or 6.5?

Yep, it's a known bug called "early template instantiation" (ETI). It's
briefly described here -
http://lists.boost.org/MailArchives/boost/msg39915.php.

> Are there any workarounds?

Sure. In your case, it would be as simple as this:

#include <boost/mpl/aux_/msvc_eti_base.hpp>

...

template< class Derived,
          class Context,
          class Transitions = empty_list,
          class InnerInitial = empty_list >
class simple_state : public mpl::aux::msvc_eti_base< typename
state_base_type<
// ^^^^^^^^^^^^^^^^^^^^^^^^
  Derived, Context, Transitions, InnerInitial >::type >::type {};

You will need the latest CVS for that, though.

Aleksey


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk