-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[clang] CTAD alias: Respect explicit deduction guides defined after the first use of the alias template. #125478
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -234,11 +234,23 @@ int i = 0; | |
| AFoo s{i}; | ||
| static_assert(__is_same(decltype(s.t), int)); | ||
|
|
||
| template<class T> | ||
| using BFoo = AFoo<T>; | ||
|
||
|
|
||
| // template explicit deduction guide. | ||
| template<class T> | ||
| Foo(T) -> Foo<float>; | ||
| static_assert(__is_same(decltype(AFoo(i).t), float)); | ||
| static_assert(__is_same(decltype(BFoo(i).t), float)); | ||
|
|
||
| // explicit deduction guide. | ||
| Foo(int) -> Foo<X>; | ||
| AFoo s2{i}; | ||
| // FIXME: the type should be X because of the above explicit deduction guide. | ||
| static_assert(__is_same(decltype(s2.t), int)); | ||
| static_assert(__is_same(decltype(AFoo(i).t), X)); | ||
| static_assert(__is_same(decltype(BFoo(i).t), X)); | ||
|
|
||
| Foo(double) -> Foo<int>; | ||
| static_assert(__is_same(decltype(AFoo(1.0).t), int)); | ||
| static_assert(__is_same(decltype(BFoo(1.0).t), int)); | ||
|
||
| } // namespace test16 | ||
|
|
||
| namespace test17 { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be null right? So we'd be inserting a bunch of nullptr into the map which is harmless but also not useful
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added an assertion -- this cannot be nullptr in theory. The function is only called for the alias templates, if a deduction guide exists for a type alias, then it must be generated from a source deduction guide by definition.