clang-concepts-monorepo icon indicating copy to clipboard operation
clang-concepts-monorepo copied to clipboard

Friend declarations are not working?

Open marehr opened this issue 5 years ago • 1 comments

template <typename>
concept AnyType = true;

template <AnyType ... types>
class configuration
{
    //!\brief Friend declaration for other instances of the configuration.
    template <AnyType ... _types>
    friend class configuration;
};

int main()
{
    configuration<>{};
    return 0;
}
error: associated constraints differ in template redeclaration
<source>:14:5: note: in instantiation of template class 'configuration<>' requested here
    configuration<>{};
    ^
note: template is declared here

The confusing thing is that the error log is truncated and that the friend is not working.

The example works if I remove the friend declaration or exchange AnyType with typename.

See https://godbolt.org/z/iXkRlP

marehr avatar Apr 21 '19 22:04 marehr

And a follow-up question:

Is it allowed to change the constraints in the friend declaration?

    template <AnotherType ... _types> // constraint differently
    friend class configuration;

marehr avatar Apr 21 '19 23:04 marehr