I'm working on a polygon class:
// A polygon is multiple (possibly closed) polycurves.
template <typename T, typename P = _point<T,2>>
struct _polygon {
using point = P;
// default constructor
_polygon() {
offs_.push_back(0);
}
// build polygon from another type
template <typename U>
_polygon(const _polygon<U> &poly) {
pnts_.reserve(poly.pnts_.size());
offs_ = poly.offs_;
for (const auto& pnt : poly.pnts_) {
pnts_.push_back(point(pnt));
}
}
private:
vector<point> pnts_; // list of points
vector<int> offs_; // offsets of start of polychains
};
The issue is in the converting constructor. I get an errror when accessing members of the other _polygon type:
polygon.h:376:28: error: ‘std::vector, std::allocator > > sk::_new_polygon::pnts_’ is private within this context pnts_.reserve(poly.pnts_.size());
Clearly an instance of a class template C isn't friends/doesn't have visibility into another instance C, which is a little surprising to me. How can I get access to the other polygon's internals to do the conversion in this case?
Aucun commentaire:
Enregistrer un commentaire