Indiana Unversity logo[ConceptGCC]

ConceptGCC :

Re: Addable

From: Martin Sebor (sebor_at_[hidden])
Date: 2007-03-08 11:27:59


Jaakko Jarvi wrote:
> Yes, it is normal behavior.
> The operator+(foo, foo) is only in scope constrained with Addable<foo>.
> The following should work (assuming your concept_map Addable<foo>):
>
> template <Addable T>
> void bar(T t) { t + t; }

Is it possible to call the same operator+ from a non-template?
Assume I can't change the concept map.

Martin

>
> bar(foo);
>
> Cheers,
>
> Jaakko Järvi
>
>
>
> On Mar 7, 2007, at 3:37 PM, Karl Meerbergen wrote:
>
>> Hi,
>>
>> The following piece of code compiled with the current SVN version
>> produces a compilation error. Is this normal behaviour?
>>
>> Thanks,
>>
>> Karl
>>
>>
>>
>> #include <concepts>
>>
>> struct foo {} ;
>>
>> namespace std {
>>
>> concept_map Addable< foo > {
>> foo operator+( foo const& f, foo const& b ) {
>> return f ;
>> }
>> }
>> }
>>
>> int main() {
>> foo f, b ;
>>
>> f + b ;
>> }
>>
>>
>> p.cpp: In function 'int main()':
>> p.cpp:17: error: no match for 'operator+' in 'f + b'
>>
>> <Karl.Meerbergen.vcf>
>> _______________________________________________
>> ConceptGCC mailing list
>> ConceptGCC_at_[hidden]
>> http://www.osl.iu.edu/mailman/listinfo.cgi/conceptgcc
>
>
> _______________________________________________
> ConceptGCC mailing list
> ConceptGCC_at_[hidden]
> http://www.osl.iu.edu/mailman/listinfo.cgi/conceptgcc