public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jonathan Wakely <redi@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org
Subject: [gcc r12-10229] libstdc++: Fix std::tr2::dynamic_bitset support for alternate characters
Date: Mon, 18 Mar 2024 14:04:02 +0000 (GMT)	[thread overview]
Message-ID: <20240318140402.A1EB6385828E@sourceware.org> (raw)

https://gcc.gnu.org/g:22273b87425aa5bccf756ff8b1887dd6d4541588

commit r12-10229-g22273b87425aa5bccf756ff8b1887dd6d4541588
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Sat Nov 18 21:09:53 2023 +0000

    libstdc++: Fix std::tr2::dynamic_bitset support for alternate characters
    
    libstdc++-v3/ChangeLog:
    
            * include/tr2/dynamic_bitset (dynamic_bitset): Pass zero and one
            characters to _M_copy_from_string.
            * testsuite/tr2/dynamic_bitset/string.cc: New test.
    
    (cherry picked from commit 49f7620a12e35f40bb1f6088d16bde9b061dc819)

Diff:
---
 libstdc++-v3/include/tr2/dynamic_bitset            |  2 +-
 .../testsuite/tr2/dynamic_bitset/string.cc         | 36 ++++++++++++++++++++++
 2 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/include/tr2/dynamic_bitset b/libstdc++-v3/include/tr2/dynamic_bitset
index 4023b3882cb..0d2160d611d 100644
--- a/libstdc++-v3/include/tr2/dynamic_bitset
+++ b/libstdc++-v3/include/tr2/dynamic_bitset
@@ -622,7 +622,7 @@ namespace tr2
 	  // Watch for npos.
 	  this->_M_Nb = (__n > __str.size() ? __str.size() - __pos : __n);
 	  this->resize(this->_M_Nb);
-	  this->_M_copy_from_string(__str, __pos, __n);
+	  this->_M_copy_from_string(__str, __pos, __n, __zero, __one);
 	}
 
       /**
diff --git a/libstdc++-v3/testsuite/tr2/dynamic_bitset/string.cc b/libstdc++-v3/testsuite/tr2/dynamic_bitset/string.cc
new file mode 100644
index 00000000000..c7d0efac35f
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr2/dynamic_bitset/string.cc
@@ -0,0 +1,36 @@
+// { dg-do run { target c++11 } }
+
+#include <tr2/dynamic_bitset>
+#include <string>
+#include <testsuite_hooks.h>
+
+void
+test_string_ctor()
+{
+  std::tr2::dynamic_bitset<> b("101001");
+  VERIFY( b[0] == true );
+  VERIFY( b[1] == false );
+  VERIFY( b[2] == false );
+  VERIFY( b[3] == true );
+  VERIFY( b[4] == false );
+  VERIFY( b[5] == true );
+}
+
+void
+test_alt_chars()
+{
+  std::string str = "xOIOIOIOx";
+  std::tr2::dynamic_bitset<> b(str, 1, 6, 'I', 'O');
+  VERIFY( b[0] == false );
+  VERIFY( b[1] == true );
+  VERIFY( b[2] == false );
+  VERIFY( b[3] == true );
+  VERIFY( b[4] == false );
+  VERIFY( b[5] == true );
+}
+
+int main()
+{
+  test_string_ctor();
+  test_alt_chars();
+}

                 reply	other threads:[~2024-03-18 14:04 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240318140402.A1EB6385828E@sourceware.org \
    --to=redi@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    --cc=libstdc++-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).