Boost logo

Boost :

From: Eric Niebler (eric_at_[hidden])
Date: 2007-07-08 10:42:24


Larry Evans wrote:
> On 07/07/2007 11:49 AM, Eric Niebler wrote:
> [snip]
>> template<typename Expr>
>> struct wrap
>> {
>> explicit wrap(Expr const &expr)
>> {}
>> };
>>
> Thanks very much Eric; however, I found that with the following:
>
> template<typename Expr>
> struct wrap
> #define INHERIT_EXPR
> #ifdef INHERIT_EXPR
> : Expr
> #endif
> {
> explicit wrap(Expr const &expr)
> {
> std::cout<<"Wrap::CTOR\n";
> }
> };
>
> the wrap CTOR is not called when:
>
> WrapItUp::call( _1 + _2, i, i );
>
> is executed. OTOH, if INHERIT_EXPR is undefined,
> then wrap CTOR *is* called.

This is construct<> being too clever by a half. The expr<> struct
doesn't have a constructor. It uses brace initialization. The
construct<> transform tries to accommodate that by using brace
initialization for things that look like Proto expressions. But I see
now that it can't really know, so I should break this up into separate
construct<> and pod_construct<> transforms.

-- 
Eric Niebler
Boost Consulting
www.boost-consulting.com

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