I think your problem is that you should probably use make_pair here instead of tie . The tie point is to allow functions that return tuples to have a return value assigned to multiple values ββat once. For example, if Get3DPoint returns a tuple<int, int, int> , you can write
int x, y, z; tie(x, y, z) = Get3DPoint();
Because of this, tie always accepts its parameters using the << 27> link so that they can be mutated. In your case, the return values ββof begin() and end() are temporary, so they cannot be bound to non- const links.
make_pair (and make_tuple ), on the other hand, are designed to accept multiple values ββand pack them into a single pair or tuple object that can be passed. This is what you want to use in your function. If you change the code to read
std::pair<iterator, iterator> getSegments() { return std::make_pair(mSegments.begin(), mSegments.end()); }
Then your code should compile just fine.
Hope this helps!
source share