On Thu, Sep 10, 2020 at 5:30 AM Fabio Alemagna via Std-Proposals <std-proposals@lists.isocpp.org> wrote:I've been following the work on P1858 and just yesterday it occurred to me that it'd be useful to do something like this:template <typename... Ts>struct Interface{rtype<Ts> func(ptype<Ts>) ... = 0;};template <typename... Ts>struct Implementation: Interface<Ts...>{rtype<Ts> func(ptype<Ts> p) override{return impl<Ts>(p);} ...};where rtype<>, ptype<> and impl<> are fictional templates with exposition-only purpose.Interesting idea, but it puts the '...' much too inconspicuously for my liking. The compiler would have to parse the entire function body before it'd be able to diagnose a missing '...' in the signature!
template <typename... T>std::any *test(){static std::any array[] = {[](T){ /* possibly very long body */}...};return array;}
Besides, recursive templates aren't needed here. You could simulate what you seem to want by just doingtemplate<class T>struct Interface {virtual rtype<T> func(ptype<T>) = 0;};template<class T>struct ImplDetail : Interface<T> {rtype<T> func(ptype<T> p) override { impl<T>(p); }};template<class... Ts>struct Implementation : ImplDetail<Ts>... {};This does involve one layer of indirection (the ImplDetail layer), but it's not recursive (not even in the colloquial sense of "recursive templates") and it's legal all the way back to C++11 IIRC.