From 380fa5bb38e3a326eaa17a676eac28c7cbd29f84 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Fri, 11 Aug 2017 22:23:51 +0200 Subject: [PATCH] DiffMessage: add further convenience ctors for STL containers --- src/lib/diff/diff-message.hpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/lib/diff/diff-message.hpp b/src/lib/diff/diff-message.hpp index 59f28a0ac..0626e3236 100644 --- a/src/lib/diff/diff-message.hpp +++ b/src/lib/diff/diff-message.hpp @@ -49,6 +49,7 @@ #include "lib/error.hpp" #include "lib/iter-source.hpp" +#include "lib/iter-adapter-stl.hpp" #include "lib/diff/tree-diff.hpp" #include "lib/diff/gen-node.hpp" #include "lib/meta/util.hpp" @@ -107,10 +108,34 @@ namespace diff{ : _FrontEnd{DiffSource::build (diffGenerationContext)} { } + /** + * Convenience builder for consuming an brace enclosed initializer_list + * @note initialiser elements will be _copied_ into a _heap alloacated_ + * snapshot (vector), which is then managed by `shared_ptr` + */ + DiffMessage(std::initializer_list const&& ili) + : DiffMessage{iter_stl::snapshot (move(ili))} + { } + + /** + * Convenience builder to piggyback any Lumiera Forward Iterator + * @note source iterator is copied into a heap allocated IterSource + */ template DiffMessage(IT ii, enable_if< can_IterForEach, void*> =nullptr) : _FrontEnd{iter_source::wrapIter(ii)} { } + + /** + * Convenience builder to use elements form any STL-like container + * @note creating heap allocated IterSource, which _refers_ to the original container + * @warning like with any classical iterators, the container must stay alive and accessible + */ + template + DiffMessage(CON& container, enable_if< __and_< can_STL_ForEach + ,__not_>>, void*> =nullptr) + : _FrontEnd{iter_source::eachEntry(container)} + { } };