Please use GitHub pull requests for new patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
libcxx/include/string
Show First 20 Lines • Show All 790 Lines • ▼ Show 20 Lines | public: | ||||
_LIBCPP_INLINE_VISIBILITY explicit basic_string(const allocator_type& __a) | _LIBCPP_INLINE_VISIBILITY explicit basic_string(const allocator_type& __a) | ||||
#if _LIBCPP_STD_VER <= 14 | #if _LIBCPP_STD_VER <= 14 | ||||
_NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value); | _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value); | ||||
#else | #else | ||||
_NOEXCEPT; | _NOEXCEPT; | ||||
#endif | #endif | ||||
#ifdef _LIBCPP_ABI_OPTIMIZE_COPY_CTOR | |||||
_LIBCPP_HIDE_FROM_ABI | |||||
#endif | |||||
basic_string(const basic_string& __str); | basic_string(const basic_string& __str); | ||||
#ifdef _LIBCPP_ABI_OPTIMIZE_COPY_CTOR | |||||
_LIBCPP_HIDE_FROM_ABI | |||||
#endif | |||||
basic_string(const basic_string& __str, const allocator_type& __a); | basic_string(const basic_string& __str, const allocator_type& __a); | ||||
#ifndef _LIBCPP_CXX03_LANG | #ifndef _LIBCPP_CXX03_LANG | ||||
_LIBCPP_INLINE_VISIBILITY | _LIBCPP_INLINE_VISIBILITY | ||||
basic_string(basic_string&& __str) | basic_string(basic_string&& __str) | ||||
#if _LIBCPP_STD_VER <= 14 | #if _LIBCPP_STD_VER <= 14 | ||||
_NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value); | _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value); | ||||
#else | #else | ||||
▲ Show 20 Lines • Show All 730 Lines • ▼ Show 20 Lines | #endif // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT | ||||
inline | inline | ||||
void __init(const value_type* __s, size_type __sz, size_type __reserve); | void __init(const value_type* __s, size_type __sz, size_type __reserve); | ||||
inline | inline | ||||
void __init(const value_type* __s, size_type __sz); | void __init(const value_type* __s, size_type __sz); | ||||
inline | inline | ||||
void __init(size_type __n, value_type __c); | void __init(size_type __n, value_type __c); | ||||
#ifndef _LIBCPP_ABI_OPTIMIZE_COPY_CTOR | |||||
_LIBCPP_HIDE_FROM_ABI | |||||
#endif | |||||
void __init_long(const basic_string& __str); | |||||
template <class _InputIterator> | template <class _InputIterator> | ||||
inline | inline | ||||
typename enable_if | typename enable_if | ||||
< | < | ||||
__is_exactly_input_iterator<_InputIterator>::value, | __is_exactly_input_iterator<_InputIterator>::value, | ||||
void | void | ||||
>::type | >::type | ||||
__init(_InputIterator __first, _InputIterator __last); | __init(_InputIterator __first, _InputIterator __last); | ||||
▲ Show 20 Lines • Show All 235 Lines • ▼ Show 20 Lines | else | ||||
__set_long_cap(__cap+1); | __set_long_cap(__cap+1); | ||||
__set_long_size(__sz); | __set_long_size(__sz); | ||||
} | } | ||||
traits_type::copy(_VSTD::__to_raw_pointer(__p), __s, __sz); | traits_type::copy(_VSTD::__to_raw_pointer(__p), __s, __sz); | ||||
traits_type::assign(__p[__sz], value_type()); | traits_type::assign(__p[__sz], value_type()); | ||||
} | } | ||||
template <class _CharT, class _Traits, class _Allocator> | template <class _CharT, class _Traits, class _Allocator> | ||||
#ifdef _LIBCPP_ABI_OPTIMIZE_COPY_CTOR | |||||
inline | |||||
#endif | |||||
void basic_string<_CharT, _Traits, _Allocator>::__init_long( | |||||
const basic_string& __str) { | |||||
const value_type* __s = _VSTD::__to_raw_pointer(__str.__get_long_pointer()); | |||||
size_type __sz = __str.__get_long_size(); | |||||
size_type __cap = __recommend(__sz); | |||||
pointer __p = __alloc_traits::allocate(__alloc(), __cap + 1); | |||||
__set_long_pointer(__p); | |||||
__set_long_cap(__cap + 1); | |||||
__set_long_size(__sz); | |||||
traits_type::copy(_VSTD::__to_raw_pointer(__p), __s, __sz); | |||||
traits_type::assign(__p[__sz], value_type()); | |||||
} | |||||
template <class _CharT, class _Traits, class _Allocator> | |||||
template <class> | template <class> | ||||
basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, const _Allocator& __a) | basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, const _Allocator& __a) | ||||
: __r_(__second_tag(), __a) | : __r_(__second_tag(), __a) | ||||
{ | { | ||||
_LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*, allocator) detected nullptr"); | _LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*, allocator) detected nullptr"); | ||||
__init(__s, traits_type::length(__s)); | __init(__s, traits_type::length(__s)); | ||||
#if _LIBCPP_DEBUG_LEVEL >= 2 | #if _LIBCPP_DEBUG_LEVEL >= 2 | ||||
__get_db()->__insert_c(this); | __get_db()->__insert_c(this); | ||||
Show All 19 Lines | basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, size_type __n, const _Allocator& __a) | ||||
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "basic_string(const char*, n, allocator) detected nullptr"); | _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "basic_string(const char*, n, allocator) detected nullptr"); | ||||
__init(__s, __n); | __init(__s, __n); | ||||
#if _LIBCPP_DEBUG_LEVEL >= 2 | #if _LIBCPP_DEBUG_LEVEL >= 2 | ||||
__get_db()->__insert_c(this); | __get_db()->__insert_c(this); | ||||
#endif | #endif | ||||
} | } | ||||
template <class _CharT, class _Traits, class _Allocator> | template <class _CharT, class _Traits, class _Allocator> | ||||
#ifdef _LIBCPP_ABI_OPTIMIZE_COPY_CTOR | |||||
inline | |||||
#endif | |||||
basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str) | basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str) | ||||
: __r_(__second_tag(), __alloc_traits::select_on_container_copy_construction(__str.__alloc())) | : __r_(__default_value_tag(), __alloc_traits::select_on_container_copy_construction(__str.__alloc())) | ||||
{ | { | ||||
if (!__str.__is_long()) | if (!__str.__is_long()) | ||||
__r_.first().__r = __str.__r_.first().__r; | __r_.first().__r = __str.__r_.first().__r; | ||||
else | else | ||||
__init(_VSTD::__to_raw_pointer(__str.__get_long_pointer()), __str.__get_long_size()); | __init_long(__str); | ||||
#if _LIBCPP_DEBUG_LEVEL >= 2 | #if _LIBCPP_DEBUG_LEVEL >= 2 | ||||
__get_db()->__insert_c(this); | __get_db()->__insert_c(this); | ||||
#endif | #endif | ||||
} | } | ||||
template <class _CharT, class _Traits, class _Allocator> | template <class _CharT, class _Traits, class _Allocator> | ||||
#ifdef _LIBCPP_ABI_OPTIMIZE_COPY_CTOR | |||||
inline | |||||
#endif | |||||
basic_string<_CharT, _Traits, _Allocator>::basic_string( | basic_string<_CharT, _Traits, _Allocator>::basic_string( | ||||
const basic_string& __str, const allocator_type& __a) | const basic_string& __str, const allocator_type& __a) | ||||
: __r_(__second_tag(), __a) | : __r_(__default_value_tag(), __a) | ||||
{ | { | ||||
if (!__str.__is_long()) | if (!__str.__is_long()) | ||||
__r_.first().__r = __str.__r_.first().__r; | __r_.first().__r = __str.__r_.first().__r; | ||||
else | else | ||||
__init(_VSTD::__to_raw_pointer(__str.__get_long_pointer()), __str.__get_long_size()); | __init_long(__str); | ||||
#if _LIBCPP_DEBUG_LEVEL >= 2 | #if _LIBCPP_DEBUG_LEVEL >= 2 | ||||
__get_db()->__insert_c(this); | __get_db()->__insert_c(this); | ||||
#endif | #endif | ||||
} | } | ||||
#ifndef _LIBCPP_CXX03_LANG | #ifndef _LIBCPP_CXX03_LANG | ||||
template <class _CharT, class _Traits, class _Allocator> | template <class _CharT, class _Traits, class _Allocator> | ||||
▲ Show 20 Lines • Show All 2,505 Lines • Show Last 20 Lines |