Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cpp: make isl objects compatible with standard containers. #13

Open
ftynse opened this issue Aug 4, 2017 · 5 comments
Open

cpp: make isl objects compatible with standard containers. #13

ftynse opened this issue Aug 4, 2017 · 5 comments

Comments

@ftynse
Copy link
Member

ftynse commented Aug 4, 2017

In particular, std::set and std::map expect objects to be less-than-comparable and std::unordered_set and std::unordered_map to have a specialization of std::hash.

C++11 stuff could go in a separate file that is conditionally included based on the C++ version.

@tobiasgrosser
Copy link
Member

The bindings are already C++11 of larger. Not sure if this would change anything regarding the separate file.

And yes, I think it would be great to systematically think about less-than and hashability. Your point of needing a std::hash for id was a certainly a good one.

@ftynse
Copy link
Member Author

ftynse commented Aug 4, 2017

Sorry, I've mistaken that for the generator file, which is not C++11. Nevermind.

For hashes there are two options: either we can wrap around isl_*_get_hash() or just compute a hash of the pointer with the standard hashing function.

@tobiasgrosser
Copy link
Member

This likely depends what you want. isl_*_get_hash gives identical hashes for different objects that model the same set. The pointer does not carry this information.

@ftynse
Copy link
Member Author

ftynse commented Aug 4, 2017

Well, I think it is reasonable to expect hashes of logically equal (i.e. represent the same set) values to be equal.

@tobiasgrosser
Copy link
Member

There are good reasons for expecting logical equality. On the other side, hashing can be expensive this way. Assume you insert a large isl::set into a hashtable and you first need to scan the full isl::set. I feel there is a tradeoff.

@tobiasgrosser tobiasgrosser changed the title Make isl objects compatible with standard containers. cpp: make isl objects compatible with standard containers. Aug 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants