]> git.tdb.fi Git - libs/math.git/blobdiff - source/geometry/union.h
Rewrite composite shape vector constructors with iterator ranges
[libs/math.git] / source / geometry / union.h
index fadeff2ac9270dd71718aade2e733504e6a44e5b..13eb7080442c625369f2c565fbb71405df5c9955 100644 (file)
@@ -23,9 +23,13 @@ struct UnionOps
 template<typename T, unsigned D>
 class Union: public CompositeShape<T, D, UnionOps<T, D> >
 {
+private:
+       Union() { }
 public:
        Union(const Shape<T, D> &, const Shape<T, D> &);
-       Union(const std::vector<Shape<T, D> *> &);
+
+       template<typename Iter>
+       static Union from_iterator_range(const Iter &, const Iter &);
 
        virtual Union *clone() const;
 };
@@ -36,14 +40,18 @@ inline Union<T, D>::Union(const Shape<T, D> &s1, const Shape<T, D> &s2):
 { }
 
 template<typename T, unsigned D>
-inline Union<T, D>::Union(const std::vector<Shape<T, D> *> &s):
-       CompositeShape<T, D, UnionOps<T, D> >(s)
-{ }
+template<typename Iter>
+inline Union<T, D> Union<T, D>::from_iterator_range(const Iter &begin, const Iter &end)
+{
+       Union<T, D> shape;
+       shape.init_from_iter_range(begin, end);
+       return shape;
+}
 
 template<typename T, unsigned D>
 inline Union<T, D> *Union<T, D>::clone() const
 {
-       return new Union<T, D>(this->shapes);
+       return new Union<T, D>(*this);
 }