I have the following problem. Consider the classes
class face {
virtual std::vector<ptr>& get_vertices(void) const = 0;
};
class triangle : public face {
private:
std::vector<ptr> vertices;
public:
std::vector<ptr>& get_vertices(void) const { return vertices; };
};
class quadrilateral : public face {
private:
std::vector<ptr> vertices;
public:
std::vector<ptr>& get_vertices(void) const { return vertices; };
};
Obviously, a triangle and quadrilateral will always have 3 and 4 vertices respectively. Thus, I would like to exchange std::vector by std::array of appropriate size to save the overhead induced by the three additional pointers in std::vector. (This is because I will have millions of faces ...) Now, is there a chance to have a common access function in face with std::array as with std::vector above? With a standard C-array, I would simply return a pointer to the first array entry and its size. Is there a STL-way to do the same or something similar? Or is there any other nice way to achieve this functionality?
Thanks for reading and possibly answering!! Andreas
additional pointers in std::vectorare you talking about?virtual ptr& operator[](unsigned idx);, and another function for getting their count.