Boost logo

Boost :

From: Howard Hinnant (hinnant_at_[hidden])
Date: 2002-03-08 10:56:35


On Friday, March 8, 2002, at 10:20 AM, Gabriel Dos Reis wrote:

> Howard Hinnant <hinnant_at_[hidden]> writes:
>
> | On Thursday, March 7, 2002, at 06:35 PM, rwgk wrote:
> |
> | > In the future, assuming that typeof is accepted into the standard,
> | > will I be able to do this ...
> | >
> | > template<typename TypeLHS, typename TypeRHS>
> | > struct binary_operator_traits {
> | > typedef typeof(TypeLHS() + TypeRHS()) arithmetic;
> | > };
> | >
> | > ... and avoid all the specializations?
> |
> | Hopefully yes. You can do this with Metrowerks today, although by
> | default typeof is spelled __typeof__. And it might be better to do
> the
> | following to avoid requiring an accessible default constructor:
> |
> | template <class T> T make();
> |
> | template<typename TypeLHS, typename TypeRHS>
> | struct binary_operator_traits {
> | typedef typeof(make<TypeLHS>() + make<TypeRHS>()) arithmetic;
>
> However, this would require a definition for make()...

Actually no. typeof (at least ours) works like sizeof. Expressions are
not evaluated. No definition of make() is required (or desired).

-Howard


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