Indiana Unversity logo[ConceptGCC]

ConceptGCC :

Re: Addable

From: Martin Sebor (sebor_at_[hidden])
Date: 2007-03-08 16:39:25


Doug Gregor wrote:
> On Mar 8, 2007, at 2:50 PM, Martin Sebor wrote:
>> Okay, thanks.
>>
>> I don't think it's part of the proposal but I think it might
>> be useful to make it possible to use the same syntax in
>> non-template code as within templates. Maybe via a using
>> declaration or directive:
>>
>> int main () {
>> foo a, b;
>> using std::Addable<foo>::operator+;
>> // or using std::Addable<foo> to get all signatures
>> foo c = a + b;
>> }
>>
>> Has this been considered and would it be feasible?
>
> It's been considered, but it does not appear feasible. Doing
> something like this:
>
> using std::Addable<int>::operator+;
>
> means that we would essentially be changing the meaning of the built-
> in operator+ for integers (!)

We're already doing that in templates. How cool is that?! ;-)

FWIW, I suspect there is quite a bit of code out there (I know
we have some) where ordinary functions participate in the same
overload set as function template specializations (explicit or
implicit) when resolving calls from function templates. Ending
up with calls to different functions depending on whether the
call is made directly from a template or indirectly through an
intermediate call to a non-template overload would, IMO, be
surprising. This seems close to the issue we discussed at our
meeting (the behavior of calls to unconstrained templates from
constrained ones).

Martin