Indiana Unversity logo[ConceptGCC]

ConceptGCC :

Re: Requiring a function template specialization

From: Walter E Brown (wb_at_[hidden])
Date: 2007-06-06 20:40:09


On 2007-06-06 7:22 PM, Douglas Gregor wrote:
> On Jun 6, 2007, at 4:36 PM, 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,
>
> A template specialization has to specialize something. In this case,
> there is no primary template to be specialized. One thing you can do
> is write this:
>
> concept Foo<class T> {
> T foo();
> }
>
> You can call it as just "foo()", or (to be more specific), Foo<T>::foo
> ().

Thank you. I understand your point regarding a primary template and had
also tried:

#include <concepts>

template< class T >
T
   foo();

concept Foo< class T >
{
   template<>
   T
     foo<T>();
};

but conceptgcc-boostcon still gives an ICE.

The intent is to be able to call foo<mytype>(), and to require the
existence of such a specialization in order for mytype to meet the Foo
concept. How can I better express this?

-- WEB