Indiana Unversity logo[ConceptGCC]

ConceptGCC :

Re: Associated type as return type.

From: hirohito none (hitobasira_at_[hidden])
Date: 2008-08-19 18:26:21


> Default implementations can only use operations
> known to work on the type, e.g., other operations within the concept Foo.

I find in the draft that "A default implementation of an associated
function is a constrained template"
But that means following code is ill-formed?

auto concept Foo< typename T >
{
        // I have to comment out bellow code?
        // void T::func() ;
        void func(T & x) { x.func() ; }
}

But ConceptGCC complains following code.

auto concept has_func< typename T >
{
    requires std::CopyConstructible< T > ;
    void T::func() ;// If I delete this line. ConceptGCC does not complains.
    void func(T & x) { x.func() ; }
}

template < typename T > requires has_func< T >
void f( T x )
{ func(x) ; }

struct Foo
{ void func(){ } } ;

int main()
{ f( Foo() ) ; }

It's just ConceptGCC does not implement draft correctly?

> This cannot be done directly. You'll need to write an accessor function like
> "function" above, and then provide an implementation for "function" within a
> concept map.

I'm disappointed about that. That's tedius.
Although I didn't write template code that access it's member
variables, I wondered how can I write concept for C++03 template code.