diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2016-11-15 14:33:20 +0000 |
---|---|---|
committer | Jonathan Wakely <redi@gcc.gnu.org> | 2016-11-15 14:33:20 +0000 |
commit | bf56b0b8384cfcc5142f24eeb8f837cc974f8119 (patch) | |
tree | 8cf08077d9c514a5fdd813dcdd432eccc7773295 /libstdc++-v3/testsuite/21_strings/basic_string/cons/char/9.cc | |
parent | 8b99f005cbf2fdc6968d75a13cd2c166795418b7 (diff) | |
download | gcc-bf56b0b8384cfcc5142f24eeb8f837cc974f8119.tar.gz |
Add std::string constructor for substring of string_view (LWG 2742)
* doc/xml/manual/intro.xml: Document LWG 2742 status.
* doc/html/*: Regenerate.
* include/bits/basic_string.h
(basic_string(const T&, size_type, size_type, const Allocator&)): Add
constructor for substring of basic_string_view, as per LWG 2742 but
with additional constraint to fix ambiguity.
* testsuite/21_strings/basic_string/cons/char/9.cc: New test.
* testsuite/21_strings/basic_string/cons/wchar_t/9.cc: New test.
From-SVN: r242416
Diffstat (limited to 'libstdc++-v3/testsuite/21_strings/basic_string/cons/char/9.cc')
-rw-r--r-- | libstdc++-v3/testsuite/21_strings/basic_string/cons/char/9.cc | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/9.cc b/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/9.cc new file mode 100644 index 00000000000..0024ffc8894 --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/9.cc @@ -0,0 +1,46 @@ +// Copyright (C) 2016 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++17" } +// { dg-do run { target c++1z } } + +#include <string> +#include <testsuite_hooks.h> + +void +test01() +{ + using C = char; + using string_type = std::basic_string<C>; + using view_type = std::basic_string_view<C>; + + std::allocator<C> alloc; + VERIFY( string_type(view_type("string")) == "string" ); + VERIFY( string_type(view_type("string"), alloc) == "string" ); + + // LWG 2742 + VERIFY( string_type("substring", 3, 6) == "string" ); + VERIFY( string_type("substring", 3, 6, alloc) == "string" ); + VERIFY( string_type(view_type("substring"), 3, 6) == "string" ); + VERIFY( string_type(view_type("substring"), 3, 6, alloc) == "string" ); +} + +int +main() +{ + test01(); +} |