Indiana Unversity logo[ConceptGCC]

ConceptGCC :

Re: Using concept maps as adapters to provide associated member functions for non-class types

From: Douglas Gregor (doug.gregor_at_[hidden])
Date: 2007-06-07 22:55:41


On Jun 7, 2007, at 8:33 PM, Tom Honermann wrote:

> I've been looking through the latest concept spec (http://www.open-
> std.org/jtc1/sc22/wg21/docs/papers/2007/n2193.pdf) and I don't see
> this mentioned explicitly there. I've been playing with code like
> the following and I'm not sure if I'm getting the syntax wrong, if
> conceptgcc doesn't yet support this, or if I'm assuming
> functionality that is not planned (and perhaps doesn't make sense).
> concept A<typename T> {
> int T::F();
> }
>
> concept_map A<char> {
> int A<char>::F() { return 1; }
> }

This functionality will not be part of concepts. When one writes a
requirement for a member function, like "int T::F()" in the concept A
above, that specifies that there really must be a member function
named 'F'. There is no way to adapt the syntax for member function
requirements in the concept map.

There are several reasons why this feature isn't available. One
reason that the syntax for doing this gets really unwieldy and very
hard to parse (for human or machine):

        concept_map A<int*> {
          int int*::F() { return 17; } // yikes!
        }

        - Doug