From 7ea786616398beec1c376925b32e96ddecb145e6 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sat, 16 Jan 2016 23:16:52 +0100 Subject: [PATCH] design fix: use type sequences and lists coherently there was a muddeled mix of type lists and type sequences, and both where used for processing. Probably the origin of that confusion was the design of our own Tuple class, which is implemented based on typelists but accepts a type sequence at the front-end. From there, a confusing pattern of equivalence between lists and sequences emerged, leading to several functions accepting "anything". This misdesign is not eradicated yet, but in this specific instance here, has cost me several hours to pinpoint a bug introduced while refactoring. See also #967 and #301 --- src/lib/meta/function-closure.hpp | 43 ++++++++++++++----------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/src/lib/meta/function-closure.hpp b/src/lib/meta/function-closure.hpp index 3c25f8042..fd5ca3926 100644 --- a/src/lib/meta/function-closure.hpp +++ b/src/lib/meta/function-closure.hpp @@ -364,32 +364,29 @@ namespace func{ /** - * Build a sequence of tr1 function argument placeholder types. - * For each of the elements of the provided reference sequence, + * Build a list of tr1 function argument placeholder types. + * For each of the elements of the provided reference list, * a Placeholder is added, numbers counting up starting with 1 (!) */ - template - class PlaceholderTuple - { - typedef typename Tuple::Type TypeSeq; - typedef typename Tuple::TailType TailSeq; - - typedef typename PlaceholderTuple::PlaceholderSeq TailPlaceholderSeq; - - public: - typedef typename Prepend<_Placeholder, TailPlaceholderSeq>::Seq PlaceholderSeq; - typedef Tuple Type; - - }; + template + struct PlaceholderTuple + : PlaceholderTuple + { }; - template - struct PlaceholderTuple, i> : PlaceholderTuple {}; + template + struct PlaceholderTuple, i> + { + using TailPlaceholders = typename PlaceholderTuple::List; + + using List = Node<_Placeholder, TailPlaceholders>; + using Type = Tuple::Seq>; + }; template struct PlaceholderTuple { - typedef Types<> PlaceholderSeq; - typedef Tuple > Type; + using List = NullType; + using Type = Tuple>; }; @@ -490,8 +487,8 @@ namespace func{ typedef typename Splice::Front RightReduced; // build a list, where each of the *remaining* arguments is replaced by a placeholder marker - typedef typename func::PlaceholderTuple::PlaceholderSeq::List LeftPlaceholders; - typedef typename func::PlaceholderTuple::PlaceholderSeq::List RightPlaceholders; + typedef typename func::PlaceholderTuple::List LeftPlaceholders; + typedef typename func::PlaceholderTuple::List RightPlaceholders; // ... and splice these placeholders on top of the original argument type list, // thus retaining the types to be closed, but setting a placeholder for each remaining argument @@ -688,8 +685,8 @@ namespace func{ typedef typename Splice::Front RemainingFront; typedef typename Splice::Back RemainingBack; - typedef typename func::PlaceholderTuple::PlaceholderSeq::List PlaceholdersBefore; - typedef typename func::PlaceholderTuple::PlaceholderSeq::List PlaceholdersBehind; + typedef typename func::PlaceholderTuple::List PlaceholdersBefore; + typedef typename func::PlaceholderTuple::List PlaceholdersBehind; typedef typename Append< typename Append< PlaceholdersBefore , ValList >::List , PlaceholdersBehind >::List PreparedArgs;