/* TupleRecordInit(Test) - to build a tuple from a GenNode sequence Copyright (C) Lumiera.org 2016, Hermann Vosseler This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * *****************************************************/ /** @file tuple-record-init-test.cpp ** Metaprogramming: how to unload the contents of a runtime typed variant sequence ** into ctor arguments of a (compile time typed) tuple. This involves two problems ** - how to combine iteration, compile-time indexing and run-time access. ** - how to overcome the runtime-to-compiletime barrier, using a pre-generated ** double-dispatch (visitor). ** ** The concrete problem prompting this research is the necessity to receive ** a command invocation parameter tuple from a Record ** */ typedef unsigned int uint; #include "lib/test/run.hpp" #include "lib/symbol.hpp" #include "lib/time/timevalue.hpp" #include "lib/meta/tuple-record-init.hpp" #include "lib/format-cout.hpp" #include "lib/format-util.hpp" #include #include using lib::Literal; using lib::Variant; using lib::idi::EntryID; using lib::diff::Rec; using lib::diff::MakeRec; using lib::diff::GenNode; using lib::meta::Types; using lib::meta::Tuple; using lib::meta::buildTuple; using lib::time::TimeVar; using lib::time::Time; using std::string; using std::tuple; namespace lib { namespace meta { namespace test { ////////////////////////TODO reworked for function-closure.hpp template struct SomeArgs { template using IdxSelector = typename lib::meta::func::PartiallyInitTuple::template IndexMapper; static Tuple doIt (Tuple const& args) { return lib::meta::TupleConstructor (args); } }; ////////////////////////TODO reworked for function-closure.hpp #define SHOW_TYPE(_TY_) \ cout << "typeof( " << STRINGIFY(_TY_) << " )= " << lib::meta::typeStr<_TY_>() < ::value) EVAL_PREDICATE(is_arithmetic ::value) EVAL_PREDICATE(is_floating_point::value) EVAL_PREDICATE(is_nonFloat ::value) EVAL_PREDICATE(GenNodeAccessor ::allow_Conversion ::value) EVAL_PREDICATE(GenNodeAccessor::allow_Conversion::value) EVAL_PREDICATE(GenNodeAccessor::allow_Conversion::value) EVAL_PREDICATE(GenNodeAccessor::allow_Conversion ::value) EVAL_PREDICATE(GenNodeAccessor::allow_Conversion ::value) EVAL_PREDICATE(GenNodeAccessor::allow_Conversion::value) EVAL_PREDICATE(GenNodeAccessor ::allow_Conversion ::value) EVAL_PREDICATE(GenNodeAccessor ::allow_Conversion::value) EVAL_PREDICATE(GenNodeAccessor::allow_Conversion::value) EVAL_PREDICATE(GenNodeAccessor::allow_Conversion::value) EVAL_PREDICATE(GenNodeAccessor ::allow_Conversion::value) cout <; using UgglyTypes = Types, string, int, int64_t, double, TimeVar>; Rec args = MakeRec().scope("lalü", 42); Rec urgs = MakeRec().scope("lalü", "lala", 12, 34, 5.6, Time(7,8,9)); cout << args < (args) < (urgs) <::doIt(std::make_tuple("hui", 88)) <