Skip to content

missed constraints equivalence put in a different position when defining a class function outside a class #119745

@mrussoLuxoft

Description

@mrussoLuxoft

Here the example where the function definition uses a requires clause whereas
the function declaration uses a concept applied directly to the template parameter type:

https://godbolt.org/z/YMxbrY5rP

template<typename T>
concept C = true;

// declaration:

template<C T>
class A1{
public:
    template<C Tnest>
    void f();
};

//definition:

template<C T>
template<typename Tnest>
requires C<Tnest>
void A1<T>::f(){};

Standard text in [temp.constr.decl]-p3 reads that the logical AND of all constraints need to be considered.
Indeed, gcc accepts it (MVSC does not).

Note that at the referred link, there is also another example with class A2, involving a constraint that is a logical OR of two other constraint, but all compilers fails if I explicit the OR in the requires clause... which seems to be fair, isn't it ?

Really, you can simplify the example by making classes as non-template, you would get the same results: https://godbolt.org/z/PdMzqG6z5

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"conceptsC++20 conceptsdiverges-from:gccDoes the clang frontend diverge from gcc on this issueinvalidResolved as invalid, i.e. not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions