OSDN Git Service

2009-12-10 Paolo Carlini <paolo.carlini@oracle.com>
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / include / ext / sso_string_base.h
index 0b576ba..d88297f 100644 (file)
@@ -1,11 +1,11 @@
 // Short-string-optimized versatile string base -*- C++ -*-
 
-// Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
+// Copyright (C) 2005, 2006, 2007, 2008, 2009 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 2, or (at your option)
+// 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,
 // 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 COPYING.  If not, write to the Free
-// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// USA.
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
 
-// As a special exception, you may use this file as part of a free software
-// library without restriction.  Specifically, if other files instantiate
-// templates or use macros or inline functions from this file, or you compile
-// this file and link it with other files to produce an executable, this
-// file does not by itself cause the resulting executable to be covered by
-// the GNU General Public License.  This exception does not however
-// invalidate any other reasons why the executable file might be covered by
-// the GNU General Public License.
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+// <http://www.gnu.org/licenses/>.
 
 /** @file ext/sso_string_base.h
  *  This file is a GNU extension to the Standard C++ Library.
@@ -175,13 +170,17 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
       }
 
       __sso_string_base()
-      : _M_dataplus(_Alloc(), _M_local_data)
+      : _M_dataplus(_M_local_data)
       { _M_set_length(0); }
 
       __sso_string_base(const _Alloc& __a);
 
       __sso_string_base(const __sso_string_base& __rcs);
 
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+      __sso_string_base(__sso_string_base&& __rcs);
+#endif
+
       __sso_string_base(size_type __n, _CharT __c, const _Alloc& __a);
 
       template<typename _InputIterator>
@@ -336,6 +335,30 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
     : _M_dataplus(__rcs._M_get_allocator(), _M_local_data)
     { _M_construct(__rcs._M_data(), __rcs._M_data() + __rcs._M_length()); }
 
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+  template<typename _CharT, typename _Traits, typename _Alloc>
+    __sso_string_base<_CharT, _Traits, _Alloc>::
+    __sso_string_base(__sso_string_base&& __rcs)
+    : _M_dataplus(__rcs._M_get_allocator(), _M_local_data)
+    {
+      if (__rcs._M_is_local())
+       {
+         if (__rcs._M_length())
+           traits_type::copy(_M_local_data, __rcs._M_local_data,
+                             _S_local_capacity + 1);
+       }
+      else
+       {
+         _M_data(__rcs._M_data());
+         _M_capacity(__rcs._M_allocated_capacity);
+       }
+
+      _M_length(__rcs._M_length());
+      __rcs._M_length(0);
+      __rcs._M_data(__rcs._M_local_data);
+    }
+#endif
+
   template<typename _CharT, typename _Traits, typename _Alloc>
     __sso_string_base<_CharT, _Traits, _Alloc>::
     __sso_string_base(size_type __n, _CharT __c, const _Alloc& __a)
@@ -370,7 +393,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
            ++__beg;
          }
        
-       try
+       __try
          {
            while (__beg != __end)
              {
@@ -388,7 +411,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
                ++__beg;
              }
          }
-       catch(...)
+       __catch(...)
          {
            _M_dispose();
            __throw_exception_again;
@@ -405,7 +428,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
                   std::forward_iterator_tag)
       {
        // NB: Not required, but considered best practice.
-       if (__builtin_expect(__is_null_pointer(__beg) && __beg != __end, 0))
+       if (__is_null_pointer(__beg) && __beg != __end)
          std::__throw_logic_error(__N("__sso_string_base::"
                                       "_M_construct NULL not valid"));
 
@@ -418,9 +441,9 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
          }
 
        // Check for out_of_range and length_error exceptions.
-       try
+       __try
          { _S_copy_chars(_M_data(), __beg, __end); }
-       catch(...)
+       __catch(...)
          {
            _M_dispose();
            __throw_exception_again;
@@ -506,7 +529,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
     void
     __sso_string_base<_CharT, _Traits, _Alloc>::
     _M_mutate(size_type __pos, size_type __len1, const _CharT* __s,
-             const size_type __len2)
+             size_type __len2)
     {
       const size_type __how_much = _M_length() - __pos - __len1;