public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/106110] New: Expected ambiguity but it resolves fine
@ 2022-06-27 21:13 ted at lyncon dot se
2022-06-28 1:22 ` [Bug c++/106110] " ted at lyncon dot se
0 siblings, 1 reply; 2+ messages in thread
From: ted at lyncon dot se @ 2022-06-27 21:13 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106110
Bug ID: 106110
Summary: Expected ambiguity but it resolves fine
Product: gcc
Version: 12.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: ted at lyncon dot se
Target Milestone: ---
I made a type trait to test if a call to a function using certain arguments
would be ambiguous or not, but in the below example, where I expected that
calling the function `foo` with a `std::tuple<single_type>` would result in
ambiguity, it is not detected as such.
```
#include <iostream>
#include <tuple>
template <class T>
void foo(const std::tuple<T>&) { std::cout << "T\n"; }
template <class T, class... Ts>
void foo(const std::tuple<T, Ts...>&) { std::cout << "Ts...\n"; }
template <class... Args>
struct is_foo_call_ambiguous {
static std::true_type test(...);
template <class... AArgs>
static auto test(AArgs&&...)
-> decltype(foo(std::declval<AArgs>()...), std::false_type{});
static constexpr bool value =
decltype(test(std::declval<Args>()...))::value;
};
template <class F, class... Args>
static constexpr bool is_foo_call_ambiguous_v =
is_foo_call_ambiguous<F, Args...>::value;
int main() {
// expected `true` here, but it reports `false`:
std::cout << is_foo_call_ambiguous_v<std::tuple<int>> << '\n';
// `false` as expected:
std::cout << is_foo_call_ambiguous_v<std::tuple<int, int>> << '\n';
}
```
As can be seen here, clang++ reports it to be ambiguous:
https://godbolt.org/z/YTevWvbzz
If I understand it correctly, the added tiebreaker
(https://cplusplus.github.io/CWG/issues/1395.html) for variadic templates
should not apply here.
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c++/106110] Expected ambiguity but it resolves fine
2022-06-27 21:13 [Bug c++/106110] New: Expected ambiguity but it resolves fine ted at lyncon dot se
@ 2022-06-28 1:22 ` ted at lyncon dot se
0 siblings, 0 replies; 2+ messages in thread
From: ted at lyncon dot se @ 2022-06-28 1:22 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106110
--- Comment #1 from Ted Lyngmo <ted at lyncon dot se> ---
Sorry, the helper variable template should be:
```
template <class... Args>
static constexpr bool is_foo_call_ambiguous_v =
is_foo_call_ambiguous<Args...>::value;
```
It gives the same result: https://godbolt.org/z/bKbn8Gre7
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-06-28 1:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-27 21:13 [Bug c++/106110] New: Expected ambiguity but it resolves fine ted at lyncon dot se
2022-06-28 1:22 ` [Bug c++/106110] " ted at lyncon dot se
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).