public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/64903] New: is_partitioned should not apply a predicate more than (last - first) times
@ 2015-02-02 16:06 kariya_mitsuru at hotmail dot com
  2015-02-02 16:24 ` [Bug libstdc++/64903] " redi at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: kariya_mitsuru at hotmail dot com @ 2015-02-02 16:06 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64903

            Bug ID: 64903
           Summary: is_partitioned should not apply a predicate more than
                    (last - first) times
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: kariya_mitsuru at hotmail dot com

Created attachment 34645
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34645&action=edit
g++ -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/OHXgHtbgmm4Ak8pJ


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 =================================


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-02-02 16:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-02 16:06 [Bug libstdc++/64903] New: is_partitioned should not apply a predicate more than (last - first) times kariya_mitsuru at hotmail dot com
2015-02-02 16:24 ` [Bug libstdc++/64903] " redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).