[Patch] Second half of tr1/complex
Howard Hinnant
hhinnant@apple.com
Fri Jan 13 15:32:00 GMT 2006
On Jan 13, 2006, at 10:16 AM, Paolo Carlini wrote:
> Hi Howard,
>
>> I see one more issue that we might want to cover here. The new
>> overloads look overly generic to me, which may break user code. For
>> example, consider:
>
> I see, but then, if we want to make the library robust wrt this
> kind of,
> well, perversion ;) (*), shouldn't we start sprinkling __enable_if
> everywhere?!? Or is there a cleaner solution?
>
> Paolo.
>
> (*) Is it even legal using the 'arg' name together with a using
> namespace like this?!?
<nod> It's legal.
Concepts in C++0X may provide a cleaner solution.
I think any time we add a function template with a parameter that
isn't meant to work for user types, we need to be alert to this
issue. I admit I may be overly paranoid of this issue. But when I
first tried to fix up <cmath> with this logic and provided:
template <class T> double sqrt(T x);
to catch integral arguments, I broke real customer's code
(unfortunately not detected until after shipping). Thus was born the
motivation for enable_if, at least for me (and which took a couple
more years to materialize).
Yes, the std is chock full of overly generic code. No, at this time
I don't recommend that gcc retrofit all of it with enable_if. But
when we add new stuff, that could possibly take customers by
surprise, I do recommend being cautious in this way.
-Howard
More information about the Libstdc++
mailing list