Is it defined to provide an inverted range to C++ standard algorithms?

后端 未结 5 666
南旧
南旧 2021-01-17 19:29

Consider standard algorithms like, say, std::for_each.

template
Function for_each(InputIterator first         


        
5条回答
  •  长情又很酷
    2021-01-17 19:49

    The standard defines complexity constraints for the functions taking ranges. In the specific case of for_each (25.2.4 in the C++ standard):

    Complexity: Applies f exactly last - first times

    So it's effectively a no-op in your example.

提交回复
热议问题