On 08/11/2019 17:02, Ben Grasset via fpc-pascal wrote: > The original C++ version used "constexpr" template parameters to > determine at compile time whether or not the user-provided comparison > function was one for which it should use the "branchless" version of its > code for item partitioning or not, and based on that passed the boolean > "true" or "false" result as another constant template parameter. > > The end result of course being that the compiled code is always tuned > precisely to the given comparison function, without any kind of runtime > selection based on non-constant boolean function parameters (which is > what I've currently had to write the "branchless" choice as, defaulting > to "true" unless the user specifies otherwise.) > > With Ryan's patch, I'll at least be able to write that choice as a > constant parameter instead, although I'm unaware of any way to replicate > actually having the compiler *make* the choice.
You can't. It's the main difference between C++ templates, which is a Turing-complete programming language, and generics, which is simply a parametrising mechanic. Jonas _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal