2

I want to create a tuple/array like (0,1,2), (3,4,5). I want to store it into an unordered_set. But unordered_set didn't offer such a hash function. Can anyone tell me how can I do this?

I have read thes answer: C++ how to insert array into hash set? but I don't want to add any extra code like hash function.

1
  • There is no alternative but to add a hash function. Because std libraries don't provide the hash function for tuple and arrays. You can create your own templatized hash class which can be reused. Commented May 20, 2016 at 10:44

1 Answer 1

1
  1. I want to store [array] into an unordered_set

  2. unordered_set didn't offer such a hash function

  3. I don't want to add any extra code like hash function.

Tough luck. A hash function is mandatory. Since it's not provided by the standard library, it must be provided by you. The answer in the question you linked shows how to write a hash function for std::array.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.