Boost logo

Ublas :

From: Dima Sorkin (dsorkin_at_[hidden])
Date: 2005-07-11 05:48:49


Quoting Andrew Rieck <arieck_at_[hidden]>:
>
> Function templates would naturally solve this issue and stop you having to
> duplicate calls. In this way, the compiler is doing all the hard work.
> A traits class should not have any member functions which do actual work.
>
> Kind regards,
> Andrew
>
Hi.
 The use of "abs" etc. in traits class may be worth, if you decide to enable
"contexts" in calls to ublas:

 May be this example is too "corner case" , but anyway :) .
 Suppose that I have a "scalar" class C , which is internally isomorphic
to 2x2 matrix.
 I have two versions of what can be called "abs" for C: normA() and normB().
I want to calculate a norm of matrix of C , once by using normA() for C,
once by normB(), in the same program. By using traits , it is easy task,
without traits -- less easy (because you can have only one "abs" function for
C,
or make it a functor object with state) .
 I am not sure that I can think of something more serious now,that will
demand "abs" in traits.

Regards,
 Dima.