From 9460f79039324434b4774063c3c46d2696bccedc Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sat, 18 Nov 2017 19:28:57 +0100 Subject: [PATCH] WIP: draft how to figure out the kind of iterator ...but does not work as intended: * just forming an IterStateWrapper does not trigger SFINAE cleanly in all cases * IterStateWrapper can be formed, even when some of the extension points are missing; this will be uncovered only later, when actually using one of the operations but beyond that, the basic type selection logic can work this way --- src/lib/iter-tree-explorer.hpp | 45 ++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/src/lib/iter-tree-explorer.hpp b/src/lib/iter-tree-explorer.hpp index f52f8ae07..f8b6c4dff 100644 --- a/src/lib/iter-tree-explorer.hpp +++ b/src/lib/iter-tree-explorer.hpp @@ -72,7 +72,8 @@ #include "lib/error.hpp" -#include "lib/meta/function.hpp" +#include "lib/meta/trait.hpp" +//#include "lib/meta/function.hpp" #include "lib/iter-adapter.hpp" #include "lib/iter-stack.hpp" #include "lib/meta/trait.hpp" ////////////////TODO @@ -157,10 +158,48 @@ namespace lib { }//(End) namespace iter_explorer : predefined policies and configurations namespace { + using meta::enable_if; + using std::__and_; + using std::__not_; + using std::is_constructible; + using meta::can_IterForEach; + using meta::can_STL_ForEach; + + template + struct is_StateCore + : is_constructible, SRC> + { }; + + template + struct shall_wrap_STL_Iter + : __and_ + ,__not_> + > + { }; + + template struct _TreeExplorerTraits { - + static_assert (!sizeof(SRC), "Can not build TreeExplorer: Unable to figure out how to iterate the given SRC type."); + }; + + template + struct _TreeExplorerTraits>> + { + static_assert (!sizeof(SRC), "PLING: StateCore"); + }; + + template + struct _TreeExplorerTraits>> + { + static_assert (!sizeof(SRC), "PLING: Lumi Iter"); + }; + + template + struct _TreeExplorerTraits>> + { + static_assert (!sizeof(SRC), "PLING: STL Iter"); }; }//(End) TreeExplorer traits @@ -174,6 +213,8 @@ namespace lib { inline auto treeExplore (IT&& srcSeq) { + using SrcIter = typename _TreeExplorerTraits::SrcIter; + return TreeExplorer {std::forward(srcSeq)}; }