1

The "old" STL does not allow say std::find to be specialized to use the member functions for std::set or std::unordered_map, etc. It cannot, since the former use iterators, the latter need the containers, and from iterators there are no means to get the containers. There is even a question about that (Specializing STL algorithms so they automatically call efficient container member functions when available).

Since Range V3 finally moves the focus from iterators to ranges, one could expect that finally std::find would be specialized automatically for std::set, which in turn makes std::none_of_equal (if it were adopted) do what you'd like, etc.

However, reading its currently implementation, I see no provision for such a feature. Why?

Community
  • 1
  • 1
akim
  • 8,255
  • 3
  • 44
  • 60
  • 2
    I think it's hard to do this generically, since `find` by default operates on `==` while `set` by default operates on `<`. So even for these defaults, you'd have to require consistency between `<` and `==`. For the more general case, it's just not possible, since the order of `set` and the predicate of `find` might be unrelated. I remember a very similar question, let me see if I can find it. – dyp Mar 13 '17 at 15:55
  • @dyp if you make this an answer I'll upvote it. – Eric Niebler Mar 13 '17 at 19:10
  • 1
    Related: http://stackoverflow.com/q/20934717/ – dyp Mar 14 '17 at 08:49

0 Answers0