[ConceptGCC] |
ConceptGCC :Re: Requiring a function template specialization |
From: Walter E Brown (wb_at_[hidden])
Date: 2007-06-06 18:14:55
Thank you for the reply. Unfortunately, your assumptions as to what I
intended are not correct: I really did intend a niladic (0-argument)
foo function, so I agree with you that overloading won't suffice.
I don't know what you mean by "C++ does not support function template
non-partial specializations." If a specialization is "non-partial", it
must be a complete specialization, and C++03 certainly does support
complete specializations for function templates. If you meant that
"C++03 does not support function template partial specializations," then
I agree with you, but there is no partial specialization anywhere in my
example below.
I really do want the Foo<T> concept to require the existence of a
foo<T>() function template specialization. Because conceptgcc today
breaks (ICE) on my proposed code, I simply want to know whether that
syntax will be correct once conceptgcc is fixed. If not, what is the
correct way to specify my requirement?
And if the requirement can't be specified today, then I will argue that
we need to modify the Concepts proposal until the requirement can be
specified. I firmly believe that Concepts must be capable of specifying
an arbitrary legal C++ interface.
Thanks again for writing. Best,
-- WEB
On 2007-06-06 4:25 PM, Tom Honermann wrote:
> Hi Walter,
>
> C++ does not support function template non-partial specializations.
> Function overloading provides this capability without the need for
> specialization (non-template functions are searched for a match before
> template functions). Correct me if I am wrong, but the goal of your
> concept is just to ensure that there is a function 'foo' that can be
> called with a parameter of type 'T', yes? If so, you don't need to
> specify templating at all. Something like this should work:
>
> concept Foo< class T >
> {
> // Require a function 'foo' that accepts an rvalue
> // of type T and returns an rvalue of type T
> T foo(T);
> };
>
> In your example, 'foo' does not accept any arguments. In this case, function overloading is not possible, but you could still require that there is a function named 'foo' that accepts no parameters and returns type T. I'm assuming you just omitted the arguments in your example.
>
> Tom.
>
>
> Walter E Brown wrote:
>> I would like to express a concept, Foo<T>, that requires the existence
>> of a specialization, foo<T>, of a function template.
>>
>> I tried the following with conceptgcc-boostcon under Cygwin, but got an
>> ICE (I submitted a bug report earlier today):
>>
>> #include <concepts>
>>
>> concept Foo< class T >
>> {
>> template<>
>> T
>> foo<T>();
>> };
>>
>> Is the above the correct way to express the desired concept? Thanks,
>>
>> -- WEB
>> _______________________________________________
>> ConceptGCC mailing list
>> ConceptGCC_at_[hidden]
>> http://www.osl.iu.edu/mailman/listinfo.cgi/conceptgcc
>>
>
> --
> Oracle Email Signature Logo
> Tom Honermann | Senior Principal Software Engineer | 503.276.2354
> Oracle PeopleTools Development
> 1211 SW 5th Ave, Suite 9080, Portland, OR 97204
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> ConceptGCC mailing list
> ConceptGCC_at_[hidden]
> http://www.osl.iu.edu/mailman/listinfo.cgi/conceptgcc