CompositeShape() { }
CompositeShape(const Shape<T, D> &, const Shape<T, D> &);
- CompositeShape(const CompositeShape &);
- CompositeShape &operator=(const CompositeShape &);
template<typename Iter>
void init_from_iter_range(const Iter &, const Iter &);
+ CompositeShape(const CompositeShape &);
+ CompositeShape &operator=(const CompositeShape &);
public:
virtual ~CompositeShape();
}
template<typename T, unsigned D, typename O>
-inline CompositeShape<T, D, O>::CompositeShape(const CompositeShape<T, D, O> &other)
+inline CompositeShape<T, D, O>::CompositeShape(const CompositeShape<T, D, O> &other):
+ shapes(other.shapes)
{
- shapes.reserve(other.shapes.size());
- for(typename ShapeArray::const_iterator i=other.shapes.begin(); i!=other.shapes.end(); ++i)
- shapes.push_back((*i)->clone());
+ for(typename ShapeArray::iterator i=shapes.begin(); i!=shapes.end(); ++i)
+ *i = (*i)->clone();
+}
+
+template<typename T, unsigned D, typename O>
+inline CompositeShape<T, D, O> &CompositeShape<T, D, O>::operator=(const CompositeShape<T, D, O> &other)
+{
+ for(typename ShapeArray::iterator i=shapes.begin(); i!=shapes.end(); ++i)
+ delete *i;
+
+ shapes = other.shapes;
+ for(typename ShapeArray::iterator i=shapes.begin(); i!=shapes.end(); ++i)
+ *i = (*i)->clone();
}
template<typename T, unsigned D, typename O>