|
Boost : |
From: jsiek_at_[hidden]
Date: 2000-01-29 16:33:36
Ok, I see what you mean about the need for typeof. I just settled for
something like plus_trait, though at least the traits are already
defined for all builtin-types through the promote_trait class
(borrowed from Todd Veldhuisen).
For user-defined types they'll have to specialize the traits.
Valentin Bonnard writes:
> Dave Abrahams wrote:
>
> > on 1/29/00 3:15 PM, Valentin Bonnard at Bonnard.V_at_[hidden] wrote:
> >
> > >> Basically, the idea is to overload all the typical operators
> > >> (+, -, <, ==) for functor objects, and use Nico's composition
> > >> library as the nodes in the expression tree. It's really not
> > >> all that hard to do...
> > >
> > > How it is possible at all w/o typeof, which no compiler (not even
> > > gcc) supports ?
> > >
> > > (and even then (w/ typeof) it would be ugly)
> >
> > I did some thinking, and I think you could do it with traits. Preparing
> > types for use in operations isn't pretty, but the resulting usage would be
> > ;)
>
> template <typename T>
> T value ();
>
> typeof (value<T> () + value<U> ())
>
> can of course be rewritten
>
> template <>
> struct plus_trait<T, U>
> {
> typedef whatever result_type;
> };
>
> typename plus_trait<T, U>::result_type
>
> but if the user is required to define too much traits, then
> he will simply define a named function to do the work
> directly instead of using all the compose library.
>
> (In complex cases, the named function will be clearer than
> a bunch of combinators.)
>
> --
>
> Valentin Bonnard
>
> ------------------------------------------------------------------------
> -- Check out your group's private Chat room
> -- http://www.egroups.com/ChatPage?listName=boost&m=1
>
>
>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk