Indiana Unversity logo[ConceptGCC]

ConceptGCC :

Re: Requiring a function template specialization

From: Tom Honermann (tom.honermann_at_[hidden])
Date: 2007-06-06 17:25:28


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



oracle_sig_logo.gif