Boost logo

Boost :

Subject: Re: [boost] [Boost-users] [type traits] Extension to operator detection -> choose your preferred naming
From: alfC (alfredo.correa_at_[hidden])
Date: 2011-09-03 01:16:11


> The point I want to make is that if there were a uniform facility to
deduce

> > the result of a built-in operator over some arithmetic types then library
> > authors could do a better job at writting generic libraries on some
> exotic
> > arithmetic types and combinations, for example
> >
> > multiply_typeof_helper<double, int>::type --> double
> >
> > I just wanted to make the connection between the two problems; and
> hopeful
> > solve the has_operator and typeof_operator problem together.
>
> The operator traits can detect if the operator return value can be
> converted to a given type but not the precise return type.
>

what do you mean by "it can't"? is that a limitation of the language? or the
library?
can't the built-in type cases by hard coded, e.g.

template<>
multiply_typeof_helper<double, int>{
  typedef double type;
};

it can always be specialized, and for decltype compilers it can be by
default:

template<class T1, class T2>
multiply_typeof_helper{
  typedef decltype(T1()*T2()) type;
};

isn't this something that fits in type traits?

Alfredo


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