How would I implement a operator< for line segments that consist of a start and a end Point. I want to insert the line segments into a map so the order doesn’t need to be semantic, but it should work for all cases.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Order everything lexicographically:
Or use the ready made comparator from
tuple:Or actually use a
std::tuple<int, int>for your points and do nothing at all!Then, do the same for the lines:
To repeat, the no-work-at-all solution just uses tuples all the way: