diff --git a/STL_Extension/include/CGAL/iterator.h b/STL_Extension/include/CGAL/iterator.h index 0e72a1ed44e..fcaf8cf95fa 100644 --- a/STL_Extension/include/CGAL/iterator.h +++ b/STL_Extension/include/CGAL/iterator.h @@ -1286,10 +1286,10 @@ struct Output_visitor { namespace internal { -template < typename D, typename V = std::tuple<>, typename O = std::tuple<> > +template < typename D, bool with_drop, typename V = std::tuple<>, typename O = std::tuple<> > struct Derivator { - typedef Derivator Self; + typedef Derivator Self; Derivator() = default; Derivator(const Self&) = default; Self& operator=(const Self&) = delete; @@ -1298,12 +1298,25 @@ struct Derivator {} }; -template < typename D, typename V1, typename O1, typename... V, typename... O> -struct Derivator, std::tuple > - : public Derivator, std::tuple > +template < typename D> +struct Derivator, std::tuple<>> { - typedef Derivator, std::tuple > Self; - typedef Derivator, std::tuple > Base; + typedef Derivator, std::tuple<>> Self; + Derivator() = default; + Derivator(const Self&) = default; + Self& operator=(const Self&) = delete; + template + void tuple_dispatch(const Tuple&){} + template + Self& operator=(const T&) { return *this; } // dropping value +}; + +template < typename D, bool with_drop, typename V1, typename O1, typename... V, typename... O> +struct Derivator, std::tuple > + : public Derivator, std::tuple > +{ + typedef Derivator, std::tuple > Self; + typedef Derivator, std::tuple > Base; Derivator() = default; Derivator(const Self&) = default; @@ -1339,12 +1352,12 @@ auto to_tuple(std::tuple &t, std::index_sequence) // OutputIterator which accepts several types in *o++= and dispatches, // wraps several other output iterators, and dispatches accordingly. -template < typename V, typename O > -class Dispatch_output_iterator; +template < typename V, typename O, bool drop_unknown_value_types> +class Dispatch_output_iterator_impl; -template < typename... V, typename... O > -class Dispatch_output_iterator < std::tuple, std::tuple > - : private internal::Derivator, std::tuple >, std::tuple, std::tuple > +template < typename... V, typename... O, bool drop_unknown_value_types> +class Dispatch_output_iterator_impl < std::tuple, std::tuple, drop_unknown_value_types> + : private internal::Derivator, std::tuple, drop_unknown_value_types >, drop_unknown_value_types, std::tuple, std::tuple > , public std::tuple { static_assert(sizeof...(V) == sizeof...(O), @@ -1352,7 +1365,7 @@ class Dispatch_output_iterator < std::tuple, std::tuple > static const int size = sizeof...(V); - template + template friend struct internal::Derivator; public: @@ -1368,18 +1381,18 @@ public: private: - typedef Dispatch_output_iterator Self; - typedef internal::Derivator Base; + typedef Dispatch_output_iterator_impl Self; + typedef internal::Derivator Base; public: using Base::operator=; using Base::tuple_dispatch; - Dispatch_output_iterator(O... o) : std::tuple(o...) {} + Dispatch_output_iterator_impl(O... o) : std::tuple(o...) {} - Dispatch_output_iterator(const Dispatch_output_iterator&)=default; + Dispatch_output_iterator_impl(const Dispatch_output_iterator_impl&)=default; Self& operator=(const Self& s) { @@ -1424,6 +1437,10 @@ public: } }; + +template +using Dispatch_output_iterator = Dispatch_output_iterator_impl; + template < typename... V, typename... O> Dispatch_output_iterator, std::tuple > dispatch_output(O... o) @@ -1435,50 +1452,8 @@ dispatch_output(O... o) // Same as Dispatch_output_iterator, but has a dummy *o++= for all other types // that drops the data (same as Emptyset_iterator). -template < typename V, typename O > -class Dispatch_or_drop_output_iterator; - -template < typename... V, typename... O > -class Dispatch_or_drop_output_iterator < std::tuple, std::tuple > - : public Dispatch_output_iterator< std::tuple, std::tuple > -{ - typedef Dispatch_or_drop_output_iterator Self; - typedef Dispatch_output_iterator< std::tuple, std::tuple > Base; - - template - friend struct internal::Derivator; - -public: - - Dispatch_or_drop_output_iterator(O... o) : Base(o...) {} - - Dispatch_or_drop_output_iterator(const Dispatch_or_drop_output_iterator&)=default; - Dispatch_or_drop_output_iterator& operator=(const Dispatch_or_drop_output_iterator&)=default; - - using Base::operator=; - - Self& operator*() { return *this; } - Self& operator++() { return *this; } - Self& operator++(int) { return *this; } - - template - Self& operator=(const T&) { return *this; } - - template - Self& operator=(const std::variant< T ... >& t) { - internal::Output_visitor visitor(this); - std::visit(visitor, t); - return *this; - } - - template - Self& operator=(const std::optional< std::variant< T ... > >& t) { - internal::Output_visitor visitor(this); - if(t) std::visit(visitor, *t); - return *this; - } -}; - +template +using Dispatch_or_drop_output_iterator = Dispatch_output_iterator_impl; template < typename... V, typename... O> inline