Boost logo

Boost :

From: Gary Powell (Gary.Powell_at_[hidden])
Date: 2000-12-04 17:33:27


> My point is that right now the
> 'return_type_traits.hpp' header used by LL is not a general "types
> promotion/deduction library/framework/whatever'" that an ordinary user
> (like
> me :) could use 'out of box' (I know, it was not supposed to be such, too
> :).
> It's more, and there are some Lambda-specific parts there, which kind of
> scare
> me ;).
>
> What I want to see is a more lightweight set of components, splitted into
> a
> few categories, so I can use one of them or another for my simple
> (relatively
> to LL) stuff, and yet don't be depreseed by including into my headers a
> huge
> amount of code which I could not understand ;). Actually, personally I
> have no
> problem with that, but users of *my* library could feel different...
> And by combining all of these components together I can still get
> something
> equivalent to the current functionality in the 'return_type_traits'
> header.
> Something like our 'operators' library :).
>
Well if we split out the "action" classes and the "sub_groups" along with
the return_type_traits.hpp you could have a reasonable stand alone return
type deduction system. I made the specialization for PETE, and it turned
out to be relatively painless, although probably not obvious.

// specialization to promote all native types to my type.
template<> struct promote_code<MyType>
{ static const int value = 1000; } // long doubles are 700

template<class T1, class T2>
return_type_2<arthmetic_operation<plus_action>, T1, T2 >::type
operator+(T1 const &x, T2 const &y) {
return x + y;
}

That's not so bad now is it?

Note: We borrowed (ok stole with acknowledgements) the type promotion stuff
of this from Blitz++.

Future work, is to integrate Bill Gibbons registering of types with our type
resolution code.

I'm open to splitting this return type deduction code out into a separate
library if there is enough interest. (For LL it's at the moment just an
implementation detail.)

  -gary-


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