Skip to content

Pack indexing specifier can't be used with templated function declaration inside a class #138255

Closed
@n0F4x

Description

@n0F4x

Example:

#include <concepts>

template<typename... Ts>
using front_t = Ts...[0];

struct Foo {
    template<typename... Ts>
         requires std::same_as<Ts...[0], int>
    static auto buggy() -> void;

    template<typename... Ts>
        requires std::same_as<front_t<Ts...>, int>
    static auto working() -> void;
};

template<typename... Ts>
    requires std::same_as<Ts...[0], int>
auto Foo::buggy() -> void {}

template<typename... Ts>
    requires std::same_as<front_t<Ts...>, int>
auto Foo::working() -> void {}

int main() {
    Foo::buggy<int>();
    Foo::working<int>();
}
<source>:18:11: error: out-of-line definition of 'buggy' does not match any declaration in 'Foo'
   18 | auto Foo::buggy() -> void {}
      |           ^~~~~
<source>:6:8: note: Foo defined here
    6 | struct Foo {
      |        ^~~
1 error generated.
Compiler returned: 1

Metadata

Metadata

Assignees

Labels

clang:frontendLanguage frontend issues, e.g. anything involving "Sema"

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions