Timeline for Why template instantiation requires specialation in the case where it is already done for all cases?
Current License: CC BY-SA 4.0
Post Revisions
12 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Sep 8, 2025 at 8:23 | vote | accept | Hazret Hasanov | ||
| Sep 6, 2025 at 19:29 | answer | added | Justin Time - Reinstate Monica | timeline score: 8 | |
| Sep 6, 2025 at 17:54 | comment | added | Justin Time - Reinstate Monica |
I didn't vote to close, but I think the reason someone else did might be that this isn't a full MCVE. You may want to provide a simplified version of aml::type_list so people can plug the code into their environment of choice and compile without editing anything, presumably something like this: template<typename... Ts> struct type_list { constexpr bool empty() const { return sizeof...(Ts) == 0; } }; (You'll probably also want to add #include <iterator> and using std::empty;, so the empty(ls) compiles without issue.)
|
|
| Sep 6, 2025 at 13:49 | comment | added | Ted Lyngmo |
You could do it without the if and call to merge. I think something like this makes it clearer anyway: godbolt.org/z/35abMsTTn
|
|
| Sep 6, 2025 at 13:31 | comment | added | Jarod42 |
You probably want an else so merge branch would be discarded when empty.
|
|
| Sep 6, 2025 at 13:12 | review | Close votes | |||
| Sep 10, 2025 at 0:07 | |||||
| Sep 6, 2025 at 12:59 | comment | added | Igor Tandetnik |
Another specialization is needed because your function, you know, calls it. So _reverse<int,int,float> calls _reverse<int, float> which calls _reverse<float> which attempts to call _reverse<> - but _reverse requires at least one type, for First parameter. Hence the error.
|
|
| Sep 6, 2025 at 12:53 | comment | added | Igor Tandetnik |
_reverse accepts a type_list with at least one element. There's no overload that can accept type_list<>.
|
|
| Sep 6, 2025 at 12:50 | history | edited | Igor Tandetnik | CC BY-SA 4.0 |
added 24 characters in body
|
| Sep 6, 2025 at 12:50 | history | edited | Hazret Hasanov | CC BY-SA 4.0 |
added 2 characters in body
|
| S Sep 6, 2025 at 12:48 | review | First questions | |||
| Sep 6, 2025 at 13:33 | |||||
| S Sep 6, 2025 at 12:48 | history | asked | Hazret Hasanov | CC BY-SA 4.0 | created from wizard |