What does std::includes actually do?

后端 未结 3 1045
慢半拍i
慢半拍i 2021-02-06 23:31

From the standard, std::includes:

Returns: true if [first2, last2) is empty or if every element in the range

3条回答
  •  佛祖请我去吃肉
    2021-02-07 00:06

    I posted this in the cpplang slack, and Casey Carter responded:

    The description of the algorithm in the standard is defective. The intent is to determine [if] every element in the needle appears in order in the haystack.

    [The algorithm it actually performs is:] "Returns true if the intersection of sorted sequences R1 and R2 is equal to R2"

    Or, if we ensure we are certain of the meaning of subsequence:

    Returns: true if and only if [first2, last2) is a subsequence of [first1, last1)

    link to Casey Carter's message

提交回复
热议问题