Hacker News new | ask | show | jobs
by account42 722 days ago
That's not polymorphism as that template parameter won't be deduced in any context and you will always have to explicitly instantiate the template.
2 comments

That is still polymorphic, but as I mentioned C++ does not do the kind of type deduction that Haskell supports so you do have to explicitly instantiate the template. However, you can instantiate it based on context, for example using decltype.
challenge accepted: https://gcc.godbolt.org/z/bGdP79aEj

edit: you get pseudo call-by-name as a bonus.