Commit 10154e0d by Paolo Carlini

basic_string.h (basic_string<>:: basic_string(basic_string&&), [...]): Add.

2010-01-10  Paolo Carlini  <paolo.carlini@oracle.com>

	* include/bits/basic_string.h (basic_string<>::
	basic_string(basic_string&&), operator=(basic_string&&),
	assign(basic_string&&)): Add.
	* config/abi/pre/gnu.ver: Export new symbols.
	* include/ext/vstring.h (__versa_string<>::assign(__versa_string&&)):
	Add.
	(operator=(__versa_string&&)): Don't call clear unnecessarily.
	* include/ext/rc_string_base.h (__rc_string_base<>::
	__rc_string_base(__rc_string_base&&)): Simplify a tad.
	* testsuite/21_strings/basic_string/cons/char/moveable.cc: New.
	* testsuite/21_strings/basic_string/cons/wchar_t/moveable.cc: Likewise.
	* testsuite/ext/vstring/assign/move_assign.cc: Likewise.
	* testsuite/21_strings/basic_string/assign/char/move_assign.cc:
	Likewise.
	* testsuite/21_strings/basic_string/assign/wchar_t/move_assign.cc:
	Likewise.

From-SVN: r155788
parent a1ec0dcf
2010-01-10 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/basic_string.h (basic_string<>::
basic_string(basic_string&&), operator=(basic_string&&),
assign(basic_string&&)): Add.
* config/abi/pre/gnu.ver: Export new symbols.
* include/ext/vstring.h (__versa_string<>::assign(__versa_string&&)):
Add.
(operator=(__versa_string&&)): Don't call clear unnecessarily.
* include/ext/rc_string_base.h (__rc_string_base<>::
__rc_string_base(__rc_string_base&&)): Simplify a tad.
* testsuite/21_strings/basic_string/cons/char/moveable.cc: New.
* testsuite/21_strings/basic_string/cons/wchar_t/moveable.cc: Likewise.
* testsuite/ext/vstring/assign/move_assign.cc: Likewise.
* testsuite/21_strings/basic_string/assign/char/move_assign.cc:
Likewise.
* testsuite/21_strings/basic_string/assign/wchar_t/move_assign.cc:
Likewise.
2010-01-10 Silvius Rus <rus@google.com>
* configure.ac: Add detection of execinfo.h.
* configure: Same.
* config.h.in: Same.
* configure: Regenerate.
* config.h.in: Likewise.
* doc/xml/manual/profile_mode.xml: Add list_to_slist manual.
Also, correct user interface mistakes.
* include/Makefile.in: Add references to new include files.
* include/Makefile.am: Add references to new include files.
* include/Makefile.in: Regenerate.
* include/backward/hash_map: Remove profile include.
* include/backward/hash_set: Remove profile include.
* include/backward/hash_set: Likewise.
* include/profile/hashtable.h: Delete file.
* include/profile/iterator_tracker.h: New file.
* include/profile/vector: Add instrumentation for tracked iterator.
......
......@@ -1098,6 +1098,15 @@ GLIBCXX_3.4.14 {
_ZNSs13shrink_to_fitEv;
_ZNSbIwSt11char_traitsIwESaIwEE13shrink_to_fitEv;
# string|wstring move contructor, move assignment operator and
# move assign.
_ZNSsC1EOSs;
_ZNSbIwSt11char_traitsIwESaIwEEC1EOS2_;
_ZNSsaSEOSs;
_ZNSbIwSt11char_traitsIwESaIwEEC1EOS2_;
_ZNSs6assignEOSs;
_ZNSbIwSt11char_traitsIwESaIwEE6assignEOS2_;
_ZSt25__throw_bad_function_callv;
# std::time_get::_M_extract_wday_or_month
......
// Components for manipulating sequences of characters -*- C++ -*-
// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
// 2006, 2007, 2008, 2009
// 2006, 2007, 2008, 2009, 2010
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
......@@ -419,8 +419,12 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
/**
* @brief Default constructor creates an empty string.
*/
inline
basic_string();
basic_string()
#ifndef _GLIBCXX_FULLY_DYNAMIC_STRING
: _M_dataplus(_S_empty_rep()._M_refdata(), _Alloc()) { }
#else
: _M_dataplus(_S_construct(size_type(), _CharT(), _Alloc()), _Alloc()){ }
#endif
/**
* @brief Construct an empty string using allocator @a a.
......@@ -479,6 +483,23 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
#ifdef __GXX_EXPERIMENTAL_CXX0X__
/**
* @brief Move construct string.
* @param str Source string.
*
* The newly-created string contains the exact contents of @a str.
* @a str is a valid, but unspecified string.
**/
basic_string(basic_string&& __str)
: _M_dataplus(__str._M_dataplus)
{
#ifndef _GLIBCXX_FULLY_DYNAMIC_STRING
__str._M_data(_S_empty_rep()._M_refdata());
#else
__str._M_data(_S_construct(size_type(), _CharT(), get_allocator()));
#endif
}
/**
* @brief Construct string from an initializer list.
* @param l std::initializer_list of characters.
* @param a Allocator to use (default is default allocator).
......@@ -534,6 +555,21 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
#ifdef __GXX_EXPERIMENTAL_CXX0X__
/**
* @brief Move assign the value of @a str to this string.
* @param str Source string.
*
* The contents of @a str are moved into this string (without copying).
* @a str is a valid, but unspecified string.
**/
basic_string&
operator=(basic_string&& __str)
{
// NB: DR 1204.
this->swap(__str);
return *this;
}
/**
* @brief Set value to string constructed from initializer list.
* @param l std::initializer_list.
*/
......@@ -976,6 +1012,23 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
basic_string&
assign(const basic_string& __str);
#ifdef __GXX_EXPERIMENTAL_CXX0X__
/**
* @brief Set value to contents of another string.
* @param str Source string to use.
* @return Reference to this string.
*
* This function sets this string to the exact contents of @a str.
* @a str is a valid, but unspecified string.
*/
basic_string&
assign(basic_string&& __str)
{
this->swap(__str);
return *this;
}
#endif // __GXX_EXPERIMENTAL_CXX0X__
/**
* @brief Set value to a substring of a string.
* @param str The string to use.
......@@ -2196,15 +2249,6 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
size_type __n2) const;
};
template<typename _CharT, typename _Traits, typename _Alloc>
inline basic_string<_CharT, _Traits, _Alloc>::
basic_string()
#ifndef _GLIBCXX_FULLY_DYNAMIC_STRING
: _M_dataplus(_S_empty_rep()._M_refdata(), _Alloc()) { }
#else
: _M_dataplus(_S_construct(size_type(), _CharT(), _Alloc()), _Alloc()) { }
#endif
// operator+
/**
* @brief Concatenate two strings.
......
// Reference-counted versatile string base -*- C++ -*-
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010
// 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
......@@ -307,7 +308,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
#ifdef __GXX_EXPERIMENTAL_CXX0X__
__rc_string_base(__rc_string_base&& __rcs)
: _M_dataplus(__rcs._M_get_allocator(), __rcs._M_data())
: _M_dataplus(__rcs._M_dataplus)
{ __rcs._M_data(_S_empty_rep._M_refcopy()); }
#endif
......
......@@ -261,8 +261,6 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
operator=(__versa_string&& __str)
{
// NB: DR 1204.
// NB: DR 675.
this->clear();
this->swap(__str);
return *this;
}
......@@ -784,6 +782,23 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
return *this;
}
#ifdef __GXX_EXPERIMENTAL_CXX0X__
/**
* @brief Set value to contents of another string.
* @param __str Source string to use.
* @return Reference to this string.
*
* This function sets this string to the exact contents of @a __str.
* @a __str is a valid, but unspecified string.
*/
__versa_string&
assign(__versa_string&& __str)
{
this->swap(__str);
return *this;
}
#endif // __GXX_EXPERIMENTAL_CXX0X__
/**
* @brief Set value to a substring of a string.
* @param __str The string to use.
......
// { dg-options "-std=gnu++0x" }
// { dg-require-string-conversions "" }
// Copyright (C) 2010 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/>.
// NOTE: This makes use of the fact that we know how moveable
// is implemented on string (via swap). If the implementation changes
// this test may begin to fail.
#include <string>
#include <utility>
#include <testsuite_hooks.h>
void test01()
{
bool test __attribute__((unused)) = true;
std::string a, b;
a.push_back('1');
b.assign(std::move(a));
VERIFY( b.size() == 1 && b[0] == '1' && a.size() == 0 );
}
int main()
{
test01();
return 0;
}
// { dg-options "-std=gnu++0x" }
// { dg-require-string-conversions "" }
// Copyright (C) 2010 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/>.
// NOTE: This makes use of the fact that we know how moveable
// is implemented on string (via swap). If the implementation changes
// this test may begin to fail.
#include <string>
#include <utility>
#include <testsuite_hooks.h>
void test01()
{
bool test __attribute__((unused)) = true;
std::wstring a, b;
a.push_back(L'1');
b.assign(std::move(a));
VERIFY( b.size() == 1 && b[0] == '1' && a.size() == 0 );
}
int main()
{
test01();
return 0;
}
// { dg-options "-std=gnu++0x" }
// { dg-require-string-conversions "" }
// Copyright (C) 2010 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/>.
// NOTE: This makes use of the fact that we know how moveable
// is implemented on string (via swap). If the implementation changed
// this test may begin to fail.
#include <string>
#include <utility>
#include <testsuite_hooks.h>
void test01()
{
bool test __attribute__((unused)) = true;
std::string a, b;
a.push_back('1');
b = std::move(a);
VERIFY( b.size() == 1 && b[0] == '1' && a.size() == 0 );
std::string c(std::move(b));
VERIFY( c.size() == 1 && c[0] == '1' );
VERIFY( b.size() == 0 );
}
int main()
{
test01();
return 0;
}
// { dg-options "-std=gnu++0x" }
// { dg-require-string-conversions "" }
// Copyright (C) 2010 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/>.
// NOTE: This makes use of the fact that we know how moveable
// is implemented on string (via swap). If the implementation changed
// this test may begin to fail.
#include <string>
#include <utility>
#include <testsuite_hooks.h>
void test01()
{
bool test __attribute__((unused)) = true;
std::wstring a, b;
a.push_back(L'1');
b = std::move(a);
VERIFY( b.size() == 1 && b[0] == L'1' && a.size() == 0 );
std::wstring c(std::move(b));
VERIFY( c.size() == 1 && c[0] == L'1' );
VERIFY( b.size() == 0 );
}
int main()
{
test01();
return 0;
}
// { dg-options "-std=gnu++0x" }
// { dg-require-string-conversions "" }
// Copyright (C) 2010 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/>.
// NOTE: This makes use of the fact that we know how moveable
// is implemented on vstring (via swap). If the implementation changes
// this test may begin to fail.
#include <ext/vstring.h>
#include <utility>
#include <testsuite_hooks.h>
void test01()
{
bool test __attribute__((unused)) = true;
__gnu_cxx::__sso_string a, b;
a.push_back('1');
b.assign(std::move(a));
VERIFY( b.size() == 1 && b[0] == '1' && a.size() == 0 );
}
void test02()
{
bool test __attribute__((unused)) = true;
__gnu_cxx::__rc_string a, b;
a.push_back('1');
b.assign(std::move(a));
VERIFY( b.size() == 1 && b[0] == '1' && a.size() == 0 );
}
int main()
{
test01();
test02();
return 0;
}
// { dg-options "-std=gnu++0x" }
// { dg-require-string-conversions "" }
// Copyright (C) 2007, 2009 Free Software Foundation, Inc.
// Copyright (C) 2007, 2008, 2009, 2010 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
......@@ -20,7 +20,7 @@
// NOTE: This makes use of the fact that we know how moveable
// is implemented on deque (via swap). If the implementation changed
// is implemented on vstring (via swap). If the implementation changes
// this test may begin to fail.
#include <ext/vstring.h>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment