[LLVMbugs] [Bug 22433] New: is_partitioned should not apply a predicate more than (last - first) times

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Feb 2 08:08:01 PST 2015


http://llvm.org/bugs/show_bug.cgi?id=22433

            Bug ID: 22433
           Summary: is_partitioned should not apply a predicate more than
                    (last - first) times
           Product: libc++
           Version: unspecified
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: kariya_mitsuru at hotmail.com
                CC: llvmbugs at cs.uiuc.edu, mclow.lists at gmail.com
    Classification: Unclassified

Created attachment 13792
  --> http://llvm.org/bugs/attachment.cgi?id=13792&action=edit
clang++ -v

Please see the sample code below.

================================= sample code =================================
#include <iostream>
#include <algorithm>

int main()
{
    int v[] = { 1, 3, 5, 7, 9, 2, 4, 6, 8, 10 };
    int c = 0;
    std::cout << std::boolalpha
        << std::is_partitioned(v, v + 10, [&c](int x) { return ++c, (x & 1) !=
0; })
        << std::endl;
    std::cout << c << " times" << std::endl;
}
================================= sample code =================================

================================= output =================================
true
11 times
================================= output =================================

cf. http://melpon.org/wandbox/permlink/MY2gv2r3dbH7AvZG


The C++11 standard 25.3.13[alg.partitions]/p.3 says, "At most last - first
applications of pred."

So the sample code above should output

================================= output =================================
true
10 times
================================= output =================================

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150202/c5876577/attachment.html>


More information about the llvm-bugs mailing list