1 // Helper for accessing __cxx11::string from the ABI -*- C++ -*-
3 // Copyright (C) 2014-2017 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // Under Section 7 of GPL version 3, you are granted additional
17 // permissions described in the GCC Runtime Library Exception, version
18 // 3.1, as published by the Free Software Foundation.
20 // You should have received a copy of the GNU General Public License and
21 // a copy of the GCC Runtime Library Exception along with this program;
22 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 // <http://www.gnu.org/licenses/>.
26 #define _GLIBCXX_USE_CXX11_ABI 1
27 #define __sso_string __sso_stringxxx
32 #if ! _GLIBCXX_USE_DUAL_ABI
33 # error This file should not be compiled for this configuration.
36 namespace std
_GLIBCXX_VISIBILITY(default)
38 _GLIBCXX_BEGIN_NAMESPACE_VERSION
40 #pragma GCC diagnostic push
41 #pragma GCC diagnostic ignored "-Wabi-tag"
42 // Redefine __sso_string so that we can define and export its members
43 // in terms of the SSO std::string.
49 size_t _M_string_length
;
50 char _M_local_buf
[16];
55 char _M_bytes
[sizeof(_M_s
)];
60 __sso_string(const std::string
& s
);
61 __sso_string(const char*, size_t n
);
62 __sso_string(const __sso_string
&) noexcept
;
63 __sso_string
& operator=(const __sso_string
&) noexcept
;
65 __sso_string(__sso_string
&&) noexcept
;
66 __sso_string
& operator=(__sso_string
&&) noexcept
;
68 #pragma GCC diagnostic pop
70 __sso_string::__sso_string() : _M_str() { }
72 #if _GLIBCXX_USE_CXX11_ABI
73 static_assert(sizeof(__sso_string
) == sizeof(std::string
),
74 "sizeof(std::string) has changed");
75 static_assert(alignof(__sso_string
) == alignof(std::string
),
76 "alignof(std::string) has changed");
78 // This constructor is defined in src/c++11/cow-stdexcept.cc for COW strings
79 __sso_string::__sso_string(const std::string
& s
) : _M_str(s
) { }
82 __sso_string::__sso_string(const char* s
, size_t n
) : _M_str(s
, n
) { }
84 __sso_string::__sso_string(const __sso_string
& s
) noexcept
85 : _M_str(s
._M_str
) { }
88 __sso_string::operator=(const __sso_string
& s
) noexcept
94 __sso_string::~__sso_string() { _M_str
.~basic_string(); }
96 __sso_string::__sso_string(__sso_string
&& s
) noexcept
97 : _M_str(std::move(s
._M_str
)) { }
100 __sso_string::operator=(__sso_string
&& s
) noexcept
102 _M_str
= std::move(s
._M_str
);
106 _GLIBCXX_END_NAMESPACE_VERSION