|
Boost : |
From: Andy Little (andy_at_[hidden])
Date: 2004-07-03 18:47:24
"Doug Gregor" <dgregor_at_[hidden]> wrote
> In Boost CVS there is an implementation of result_of, which would be
> used like this:
>
> result_of<Op(A, B)>::type
I have seen this, but BTW I cant find the
utilities/detail/result_of_iterate.hpp header in the boost CVS
Of course there is no problem to do this and am all in favour of result_of
and binary_operation is designed to work with it 'out of the box'
result_of<binary_operation<A,Op,B> >::type;
This is a lot easier and less work to implement than the alternatives
result_of<plus(A,B) >::type // requires impl
result_of<minus(A,B) >::type // etc
result_of<less(A,B) >::type
etc...ad infinitum
outlined in the proposal, which as I understand it requires a templated
nested class for each currently
result_of is a a general purpose tool. My point is that when dealing with
'operators' as opposed to functions in general it is much more convenient
to have one one class representing the operation than a plethora of
result_of_xxx classes. Take a look in Lambda, Ublas etc etc... currently
they all do their own thing on operators
One common interface class (ie binary_operation) for operators would sure
help when designing matrix operators etc. To do that you need a template
parameter capable of representing the generic operation.
regards
Andy Little
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk