Boost logo

Boost :

From: Andreas Huber (spam2002_at_[hidden])
Date: 2003-02-06 11:57:28


Aleksey,

> Yep, I understand that; but I was specifically interested whether
> _incomplete types_ are an important case here. If it's more than
> just a corner-case situation, I'll look into fixing it.
[snip]
> But 'is_sequence' does work on MSVC 7.0, in general. So, unless
> passing an incomplete type is a common-place situation, I would
> recommend just to document the pitfall itself.

In my application the argument passed to is_sequence is _never_ a complete
type. See below for reasons.

> It was. Fixed now in the CVS.

Thank you very much! Both apply and apply1 work now. I will use apply1 as
you recommended.

Best regards,

Andreas

P.S. The following is an outline of how I define the states of a
statemachine. Inner states must "know" their outer state for much the same
reasons as a derived class must "know" its base. However, an outer state
must also be able to define which of its inner states is the initial state
(see 1). This leads to a circular dependency that can only be broken if the
InnerInitial parameter is permitted to be an incomplete type. To support
concurrent (or orthogonal) states an outer state can have multiple inner
initial states, that's why the user can also specify a list. Finally, an
empty list means that the defined state does not have an inner state, i.e.
it is itself a leaf state (2).

// our statemachine (context of all outermost states)
class StopWatch : public /* */ { /* */ };

template<
  class Derived,
  class Context, // either an outer state or a state_machine
  class InnerInitial = mpl::list<> >
class state { /* */ };

// forward declare the inner initial state
class Running;
// the outer state
class Active : public state< Active, StopWatch, Running /* 1 */ > {};

// an inner state that happens to be the initial state
class Running : public state< Running, Active /* 2 */ > {};

// another inner state
class Paused : public state< Paused, Active /* 2 */ > {};


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