Why was pair range access removed from C++11?

I just discovered that at one point, the C++11 draft had std::begin/std::end overloads for std::pair that allowed treating a pair of iterators as a range suitable for use in a range-based for loop (N3126, section 20.3.5.5), but this has since been removed.

Does anyone know why it was removed?

I find the removal very unfortunate, because it seems there is no other way to treat a pair of iterators as a range. Indeed:

  • The lookup rules for begin/end in a range-based for loop say that begin/end are looked for in 1) as member functions of the range object 2) as free functions in "associated namespaces"
  • std::pair does not have begin/end member functions
  • The only associated namespace for std::pair in general is namespace std
  • We are not allowed to overload std::begin/std::end for std::pair ourselves
  • We cannot specialize std::begin/std::end for std::pair (because the specialization would have to be partial and that's not allowed for functions)

Is there some other way that I am missing?

54
задан Soo Wei Tan 2 May 2012 в 09:57
поделиться