A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/llvm/llvm-project/issues/53640 below:

template is considered more constrained even though function parameters are not of the same type · Issue #53640 · llvm/llvm-project · GitHub

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.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4