From 5e3088c45be2b59a9fce1e17aa042ee5083a0fc3 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Wed, 27 Sep 2017 18:39:47 +0200 Subject: [PATCH] Investigation: need to limit the scope of the quest there is the danger to get into building a fully generic solution, which is - quite hard / challenging - counterfeits the goal of writing easy-to-read code This is the very reason why I do not want to use boost::MPL, because in our usage situation, their abstractions are not worth the price in terms of hard to read code. --- research/try.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/research/try.cpp b/research/try.cpp index f8a2780f5..29ed4d5ca 100644 --- a/research/try.cpp +++ b/research/try.cpp @@ -54,12 +54,15 @@ typedef unsigned int uint; #include "lib/format-util.hpp" //#include "lib/meta/function.hpp" #include "lib/meta/tuple-helper.hpp" +#include "lib/test/test-helper.hpp" #include #include #include +#include using lib::meta::_Fun; +using lib::test::showSizeof; using std::function; using std::forward; @@ -112,6 +115,10 @@ struct Pick<0> } }; + +using Arr = std::array; + + template void dispatch_ (IndexSeq, ARGS...args) @@ -121,7 +128,7 @@ dispatch_ (IndexSeq, ARGS...args) } template -void +Arr dispatch (ARGS...args) { enum {SIZ = sizeof...(args)}; @@ -131,6 +138,8 @@ dispatch (ARGS...args) dispatch_ (First(), args...); dispatch_ (Next(), args...); + Arr arr{9,8,7}; + return arr; } @@ -140,7 +149,8 @@ main (int, char**) fun1 (1,2,3); fun2 (4,5,6); - dispatch (2,3,4,5,6,7,8); + auto arr = dispatch (2,3,4,5,6,7,8); + cout << util::join(arr) << "| " << showSizeof(arr) <