From 58898997d8128e6be6a41702ecb7edae6d351ab9 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sun, 19 Mar 2017 02:48:32 +0100 Subject: [PATCH] Function-Tools: get rid of the old-style FunctionSignature template ...it is now completely redundant, even superseded by the new _Fun signature trait (which additionally also handles lambdas) --- src/lib/iter-source.hpp | 2 +- src/lib/itertools.hpp | 26 +-- src/lib/meta/function-closure.hpp | 4 +- src/lib/meta/function.hpp | 152 ------------------ src/lib/wrapper.hpp | 4 +- src/proc/control/argument-tuple-accept.hpp | 5 +- src/proc/control/command-op-closure.hpp | 6 +- .../control/argument-tuple-accept-test.cpp | 12 +- tests/library/meta/function-closure-test.cpp | 4 +- 9 files changed, 21 insertions(+), 194 deletions(-) diff --git a/src/lib/iter-source.hpp b/src/lib/iter-source.hpp index ef4d4c157..ec97a38a4 100644 --- a/src/lib/iter-source.hpp +++ b/src/lib/iter-source.hpp @@ -282,7 +282,7 @@ namespace lib { template struct _TransformIterT { - typedef typename _ProducedOutput::Type ResVal; + typedef typename lib::meta::_Fun::Ret ResVal; typedef TransformIter TransIter; typedef typename IterSource::iterator Iter; }; diff --git a/src/lib/itertools.hpp b/src/lib/itertools.hpp index 1b36dafb4..b3fa64072 100644 --- a/src/lib/itertools.hpp +++ b/src/lib/itertools.hpp @@ -629,28 +629,6 @@ namespace lib { - namespace { // Helper to pick up the produced value type automatically - - using lib::meta::FunctionSignature; - - template - struct _ProducedOutput - { - typedef typename FunctionSignature>::Ret Type; - }; - - template - struct _ProducedOutput> - { - typedef typename FunctionSignature>::Ret Type; - }; - - template - struct _ProducedOutput - { - typedef typename FunctionSignature>::Ret Type; - }; - } /** Build a TransformIter: convenience free function shortcut, @@ -659,10 +637,10 @@ namespace lib { * @return Iterator processing the source feed */ template - inline TransformIter::Type> + inline auto transformIterator (IT const& src, FUN processingFunc) { - typedef typename _ProducedOutput::Type OutVal; + using OutVal = typename lib::meta::_Fun::Ret; return TransformIter(src,processingFunc); } diff --git a/src/lib/meta/function-closure.hpp b/src/lib/meta/function-closure.hpp index fc55fdabf..433ce95a6 100644 --- a/src/lib/meta/function-closure.hpp +++ b/src/lib/meta/function-closure.hpp @@ -476,8 +476,8 @@ namespace func{ template class TupleApplicator { - using Args = typename FunctionSignature< function>::Args; - using Ret = typename FunctionSignature< function>::Ret; + using Args = typename _Fun::Args; + using Ret = typename _Fun::Ret; using BoundFunc = function; diff --git a/src/lib/meta/function.hpp b/src/lib/meta/function.hpp index 0ca2a6374..1d63fb65f 100644 --- a/src/lib/meta/function.hpp +++ b/src/lib/meta/function.hpp @@ -63,158 +63,6 @@ namespace meta{ using std::function; - - - /** - * Extract the type information contained in a - * function or functor type, so it can be manipulated - * by metaprogramming. Up to 9 function arguments are - * supported and can be extracted as a type sequence. - * The bare function signature serving as input can be - * obtained by capturing a function reference or pointer. - */ - template< typename SIG> - struct FunctionSignature; - - - template< typename RET> - struct FunctionSignature< function > - { - typedef RET Ret; - typedef Types<> Args; - }; - - - template< typename RET - , typename A1 - > - struct FunctionSignature< function > - { - typedef RET Ret; - typedef Types Args; - }; - - - template< typename RET - , typename A1 - , typename A2 - > - struct FunctionSignature< function > - { - typedef RET Ret; - typedef Types Args; - }; - - - template< typename RET - , typename A1 - , typename A2 - , typename A3 - > - struct FunctionSignature< function > - { - typedef RET Ret; - typedef Types Args; - }; - - - template< typename RET - , typename A1 - , typename A2 - , typename A3 - , typename A4 - > - struct FunctionSignature< function > - { - typedef RET Ret; - typedef Types Args; - }; - - - template< typename RET - , typename A1 - , typename A2 - , typename A3 - , typename A4 - , typename A5 - > - struct FunctionSignature< function > - { - typedef RET Ret; - typedef Types Args; - }; - - - template< typename RET - , typename A1 - , typename A2 - , typename A3 - , typename A4 - , typename A5 - , typename A6 - > - struct FunctionSignature< function > - { - typedef RET Ret; - typedef Types Args; - }; - - - template< typename RET - , typename A1 - , typename A2 - , typename A3 - , typename A4 - , typename A5 - , typename A6 - , typename A7 - > - struct FunctionSignature< function > - { - typedef RET Ret; - typedef Types Args; - }; - - - template< typename RET - , typename A1 - , typename A2 - , typename A3 - , typename A4 - , typename A5 - , typename A6 - , typename A7 - , typename A8 - > - struct FunctionSignature< function > - { - typedef RET Ret; - typedef Types Args; - }; - - - template< typename RET - , typename A1 - , typename A2 - , typename A3 - , typename A4 - , typename A5 - , typename A6 - , typename A7 - , typename A8 - , typename A9 - > - struct FunctionSignature< function > - { - typedef RET Ret; - typedef Types Args; - }; - - - - - - /** * Helper for uniform access to function signature types. * Extract the type information contained in a function or functor type, diff --git a/src/lib/wrapper.hpp b/src/lib/wrapper.hpp index 24e2bd27a..9b044413b 100644 --- a/src/lib/wrapper.hpp +++ b/src/lib/wrapper.hpp @@ -56,7 +56,7 @@ namespace wrapper { using util::unConst; using util::isSameObject; - using lib::meta::FunctionSignature; + using lib::meta::_Fun; using lumiera::error::LUMIERA_ERROR_BOTTOM_VALUE; using std::function; @@ -346,7 +346,7 @@ namespace wrapper { : public function , boost::noncopyable { - using Res = typename FunctionSignature>::Ret; + using Res = typename _Fun::Ret; using ResWrapper = ItemWrapper; ResWrapper lastResult_; diff --git a/src/proc/control/argument-tuple-accept.hpp b/src/proc/control/argument-tuple-accept.hpp index d7777804a..c05ef4e6a 100644 --- a/src/proc/control/argument-tuple-accept.hpp +++ b/src/proc/control/argument-tuple-accept.hpp @@ -591,13 +591,14 @@ namespace control { using lib::meta::Tuple; + using lib::meta::_Fun; template struct _Type { - using Args = typename FunctionSignature< function>::Args; - using Ret = typename FunctionSignature< function>::Ret; + using Args = typename _Fun::Args; + using Ret = typename _Fun::Ret; using Sig = SIG; using ArgTuple = Tuple; }; diff --git a/src/proc/control/command-op-closure.hpp b/src/proc/control/command-op-closure.hpp index 0acbd70a2..6105d9438 100644 --- a/src/proc/control/command-op-closure.hpp +++ b/src/proc/control/command-op-closure.hpp @@ -58,7 +58,7 @@ namespace proc { namespace control { - using lib::meta::FunctionSignature; + using lib::meta::_Fun; using lib::meta::Tuple; using lib::meta::BuildTupleAccessor; using lib::meta::func::TupleApplicator; @@ -153,10 +153,10 @@ namespace control { template class OpClosure { - using Args = typename FunctionSignature< function>::Args; + using Args = typename _Fun::Args; using Builder = BuildTupleAccessor; - using ParamStorageTuple =typename Builder::Product; + using ParamStorageTuple = typename Builder::Product; ParamStorageTuple params_; bool activated_; diff --git a/tests/core/proc/control/argument-tuple-accept-test.cpp b/tests/core/proc/control/argument-tuple-accept-test.cpp index bc511feb4..f328a6540 100644 --- a/tests/core/proc/control/argument-tuple-accept-test.cpp +++ b/tests/core/proc/control/argument-tuple-accept-test.cpp @@ -41,7 +41,7 @@ namespace test { using lib::time::TimeVar; using std::function; - using lib::meta::FunctionSignature; + using lib::meta::_Fun; using lib::meta::Tuple; @@ -54,9 +54,9 @@ namespace test { template struct _Tup { - typedef typename FunctionSignature< function>::Args Args; - typedef typename FunctionSignature< function>::Ret Ret; - typedef Tuple Ty; + using Args = typename _Fun::Args; + using Ret = typename _Fun::Ret; + using Ty = Tuple; }; @@ -67,8 +67,8 @@ namespace test { , typename _Tup::Ty // base class to inherit from > { - typedef typename _Tup::Ty ATuple; - typedef typename _Tup::Ret RetType; + using ATuple = typename _Tup::Ty; + using RetType = typename _Tup::Ret; public: diff --git a/tests/library/meta/function-closure-test.cpp b/tests/library/meta/function-closure-test.cpp index 56cc89685..510ebfa12 100644 --- a/tests/library/meta/function-closure-test.cpp +++ b/tests/library/meta/function-closure-test.cpp @@ -142,8 +142,8 @@ namespace test { check_signatureTypeManip () { typedef int someFunc(Num<5>,Num<9>); - typedef FunctionSignature>::Ret RetType; // should be int - typedef FunctionSignature>::Args Args; + typedef _Fun::Ret RetType; // should be int + typedef _Fun::Args Args; DISPLAY (Args); typedef Prepend, Args>::Seq NewArgs; // manipulate the argument type(s)