Inherits O.
template<typename V, typename O>
class CGAL::Dispatch_or_drop_output_iterator< V, O >
The class Dispatch_or_drop_output_iterator
defines an OutputIterator
that contains a tuple of output iterators, and dispatches among those based on the type of the value type which is put in it.
Besides defining assignment for all parameters of V
and for a tuple of type V
, it is also defined for the types std::variant<T...>
and std::optional<std::variant<T...> >
, where T...
must be a subset of the parameters of V
. Should the std::optional
be empty, it will be discarded.
Parameters
- Template Parameters
-
V | must be a std::tuple<...> of the types of values to be accepted and dispatched. |
O | must be a std::tuple<...> of the types of corresponding output iterators. |
- Is model of
OutputIterator
File STL_Extension/Dispatch_output_iterator.cpp
#include <vector>
#include <CGAL/iterator.h>
#include <variant>
#include <optional>
int main()
{
std::vector<int> a;
std::vector<double> b;
std::vector<char> c;
std::tuple<int, double, char>,
std::tuple<std::back_insert_iterator< std::vector<int> >,
std::back_insert_iterator< std::vector<double> >,
std::back_insert_iterator< std::vector<char> >
> > Dispatch;
Dispatch disp = CGAL::dispatch_output<int, double, char>(
std::back_inserter(a),
std::back_inserter(b),
std::back_inserter(c));
typedef std::variant<int, double, char> var;
var va = 23; var vb = 4.2; var vc = 'x';
*disp++ = va;
*disp++ = vb;
*disp++ = vc;
*disp++ = 42;
return 0;
}
The class Dispatch_output_iterator defines an OutputIterator that contains a tuple of output iterator...
Definition iterator.h:214
- See also
CGAL::Dispatch_output_iterator<V,O>