diff --git a/research/try.cpp b/research/try.cpp index 9682dfeed..f8a2780f5 100644 --- a/research/try.cpp +++ b/research/try.cpp @@ -86,51 +86,25 @@ fun2 (int const& i, int const& j, int const& k) } - /** Hold a sequence of index numbers as template parameters */ - template - struct IndexSeq - { - template - using AppendElm = IndexSeq; - }; - - /** build an `IndexSeq<0, 1, 2, ..., n-1>` */ - template - struct BuildIndexSeq - { - using Ascending = typename BuildIndexSeq::Ascending::template AppendElm; - - template - using FilledWith = typename BuildIndexSeq::template FilledWith::template AppendElm; - }; - - template<> - struct BuildIndexSeq<0> - { - using Ascending = IndexSeq<>; - - template - using FilledWith = IndexSeq<>;; - }; +using lib::meta::IndexSeq; +using lib::meta::BuildIndexSeq; -template -struct Pick; - -template -struct Pick - : Pick +template +struct Pick { + template static auto get (ARG, ARGS ...args) { - return Pick::get (args...); + return Pick::get (args...); } }; -template -struct Pick<0, ARG,ARGS...> +template<> +struct Pick<0> { + template static ARG get (ARG a, ARGS...) { @@ -143,7 +117,7 @@ void dispatch_ (IndexSeq, ARGS...args) { - fun1 (Pick::get(args...) ...); + fun2 (Pick::get(args...) ...); } template @@ -153,8 +127,10 @@ dispatch (ARGS...args) enum {SIZ = sizeof...(args)}; using First = typename BuildIndexSeq<3>::Ascending; + using Next = typename BuildIndexSeq<3>::OffsetBy<3>; - dispatch_ (First{}, args...); + dispatch_ (First(), args...); + dispatch_ (Next(), args...); } diff --git a/src/lib/meta/tuple-helper.hpp b/src/lib/meta/tuple-helper.hpp index ea940a02e..9f91650e6 100644 --- a/src/lib/meta/tuple-helper.hpp +++ b/src/lib/meta/tuple-helper.hpp @@ -214,6 +214,9 @@ namespace meta { { using Ascending = typename BuildIndexSeq::Ascending::template AppendElm; + template + using OffsetBy = typename BuildIndexSeq::template OffsetBy::template AppendElm; + template using FilledWith = typename BuildIndexSeq::template FilledWith::template AppendElm; }; @@ -223,8 +226,11 @@ namespace meta { { using Ascending = IndexSeq<>; + template + using OffsetBy = IndexSeq<>; + template - using FilledWith = IndexSeq<>;; + using FilledWith = IndexSeq<>; };