Rust is getting value-typed template parameters Real Soon Now - in fact, they now work to some extent on nightly. In the parent’s example, my guess is that only the second parameter could be changed to a value, whereas the first is actually used somewhere as a type - but I have no context so it’s just a guess.
With C++, wouldn't I need to either use a virtual base class with a typed template parameter (to emulate interfaces), or need to use duck-typed parameter and lose type safety?
Sprinkle in a bunch of std::enable_if to do SFINAE and that's it. It's a way to tell the compiler a certain function or method should be enabled only when some other compile-time condition is true.
Which of the two template arguments are you talking about? The enum-typed template argument will lead to a optimized specialization of the template. C++ does, however, have an unfortunate problem with restricting type parameters to types with certain properties/guarantees in ways that won't make the compiler explode in obtuse error messages.
static_assert, enable_if or just plain not providing default implementation and only specializations, as everything in C++ error messages is something you can customize to high extent...
Wouldn't C++ actually be more straightforward with its value-typed template parameters?