Before marking this as duplicate, I have been here, here, and here, a duplicate of the first.
I'm aware of boost::multi_index
, and use an environment where I lack it, and that a std::unordered_set
is not bound to store elements in a deterministic insertion order.
I find the concept of using two containers, say an additional std::vector
as uncouth.
What I would love is a solution involving a comparator that I can use in a std::set
's template parameters (clarification, this could be a trivial functor struct, containing a bool operator()()
overload, a regular function, or a lambda). Is it possible?
Addenda
Initialization must occur through a std:: container's begin iterator/end iterator constructor, such as in this snippet.
std::string str; cin >> str; std::set<char>(str.begin(), str.end());
Also, another interesting use-case would be to create a dumb hash wrapping functor that allows insertion order to be pushed in to a
std::unordered_set
's template parameter.