Re:Const vs. constexpr vs. consteval vs. constinit in C++20
by fluoridation on Monday November 28, 2022 @03:37PM
(#33779223)
Fair enough, but that addition wasn't to solve the problem of templates being too complex, but to support usages that were previously impossible.
Re:Const vs. constexpr vs. consteval vs. constinit in C++20
by usrnm on Monday November 28, 2022 @05:03PM
(#33780512)
They were possible and widely used, but a lot less ergonomic. You "just" had to copy-paste some number of instantiatons for the number of arguments between 0 and, say, 50.
Re:Const vs. constexpr vs. consteval vs. constinit in C++20
by fluoridation on Tuesday November 29, 2022 @07:32AM
(#33786743)
Wasn't it also at the cost of compilation memory? I still remember the time when it was easy to crash compilers by just giving them hard enough templates.
Re:Const vs. constexpr vs. consteval vs. constinit in C++20
by cbsmith on Monday November 28, 2022 @04:22PM
(#33779888)
I mean, that's just the tip of the iceberg. Templates have evolved a great deal over time, and continue to do so (C++20 added Concepts).
Re:Const vs. constexpr vs. consteval vs. constinit in C++20
by kllrnohj on Monday November 28, 2022 @06:24PM
(#33781347)
Constraints and concepts don't increase the scope or feature set of templates, which was GP's broader point. That is, all the additions are around things that are a smaller, but easier to use, subset of the broader feature. `if constexpr` for example just being a way more approachable std::enable_if, not an expansion of the feature set. And concepts then are about clarifying the contract of the template, they don't actually add new capabilities.
It'd be I think reflection, however that ends up looking, that's the next actual feature set expansion of templates.
I agree with your broader point but parameter packs (aka, variadic templates) were an addition to templates made in C++11. So strictly speaking they have gotten more complex.