Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

template is considered more constrained even though function parameters are not of the same type #53640

Closed
Labels
clang:frontendLanguage frontend issues, e.g. anything involving "Sema"conceptsC++20 concepts
@kirshamir

Description

@kirshamir

template<typename T>
concept SmallVar = (sizeof(T) <= sizeof(int));

void print(SmallVar auto t) {
std::cout << t << std::endl;
}

void print(const auto& t) {
std::cout << t << std::endl;
}

int main() {
print(6); // clang accepts, gcc sees here ambiguity
}

https://godbolt.org/z/P89dPsaKa


It seems that gcc is right in rejecting the code on ambiguity, as the function parameters that positionally correspond between the two templates are not of the same type - thus neither template should be more specialized than the other.

https://eel.is/c++draft/temp.func.order#6.2.2:
Otherwise, [...] or if the function parameters that positionally correspond between the two templates are not of the same type, neither template is more specialized than the other.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"conceptsC++20 concepts

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp