I\'m writing a custom iterator that, when dereferenced returns a tuple of references. Since the tuple itself is ephemeral, I don\'t think I can return a reference from oper
You can place the std::tuple
as a data member and return a reference to that:
class iterator
{
public:
iterator(std::vector& _v1,
std::vector& _v2)
: tup(_v1[5], _v2[5]) {}
tuple_of_references& operator*() const
{
return tup;
}
private:
typedef std::tuple tuple_of_references; // just to cut down size
tuple_of_references tup;
};