Boost logo

Boost :

From: Brian Braatz (brianb_at_[hidden])
Date: 2005-08-01 23:21:16


Suggestion:

is there some way in your design you can get away with deriving from the
incomplete type to "de-incomplete" it?

> -----Original Message-----
> From: boost-bounces_at_[hidden]
[mailto:boost-bounces_at_[hidden]]
> On Behalf Of Andreas Huber
> Sent: Monday, August 01, 2005 3:33 AM
> To: boost_at_[hidden]
> Subject: [boost] [mpl] as_sequence< X< Y > > instantiates typedefs in
X< Y
> >
>
> Hi there
>
> I'm trying to address a point raised by Jonathan Turkanis during the
> formal review of the statechart library. Basically, the problem boils
> down to the following:
>
> #include <boost/mpl/list.hpp>
> #include <boost/mpl/size.hpp>
> #include <boost/mpl/as_sequence.hpp>
>
> namespace mpl = boost::mpl;
>
> // InnerInitial is either an mpl sequence of types or a single type
> template< class InnerInitial >
> struct state
> {
> // stateArray_ must have a length equal to the number of types
> // in InnerInitial
> int stateArray_[
> mpl::size<
> typename mpl::as_sequence< InnerInitial >::type
> >::type::value
> ];
> };
>
> // A is defined later, possibly in a different translation unit
> struct A;
>
> template< class X >
> struct B
> {
> typedef typename X::reactions reactions;
> };
>
> int main()
> {
> // fine: instantiation with an incomplete type
> state< A > a;
> // fine: instantiation with an mpl sequence containing B< A >
> state< mpl::list< B< A > > > b;
> // error: mpl::as_sequence triggers the instantiation of B's member
> // typedef, which tries to access the member typedef of A. A
compile-
> // time error results because A is still incomplete at this point.
> state< B< A > > c; // *** here ***
>
> return 0;
> }
>
> MSVC7.1 and GCC3.4 agree that the last state template instantiation is
> illegal (use of undefined type A). I'm wondering whether there is any
> way to make this legal (different as_sequence implementation,
implement
> the state template differently, etc.)?
>
> Thanks & Regards,
>
> --
> Andreas Huber
>
> When replying by private email, please remove the words spam and trap
> from the address shown in the header.
>
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost


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