diff options
author | Marshall Clow <mclow.lists@gmail.com> | 2014-06-10 18:51:55 +0000 |
---|---|---|
committer | Marshall Clow <mclow.lists@gmail.com> | 2014-06-10 18:51:55 +0000 |
commit | 9b0af34d9641156ee1c0ff7e1d1ff9386dd55d35 (patch) | |
tree | 0c16817074410a12f076e5ca4c3c47e686dab516 /libcxx/include/string | |
parent | 98763eb52091bf02f2443d334792b0f79be3d1ed (diff) | |
download | bcm5719-llvm-9b0af34d9641156ee1c0ff7e1d1ff9386dd55d35.tar.gz bcm5719-llvm-9b0af34d9641156ee1c0ff7e1d1ff9386dd55d35.zip |
Make the helper routines in string really be constexpr. This required a bit of refacoring in algorithm as well. Give them better names while we're at it. All of these are internal rotines; no visible functionality change.
llvm-svn: 210561
Diffstat (limited to 'libcxx/include/string')
-rw-r--r-- | libcxx/include/string | 88 |
1 files changed, 45 insertions, 43 deletions
diff --git a/libcxx/include/string b/libcxx/include/string index bb8f111e1a0..d07ff289bb6 100644 --- a/libcxx/include/string +++ b/libcxx/include/string @@ -990,10 +990,10 @@ char_traits<char32_t>::assign(char_type* __s, size_t __n, char_type __a) // helper fns for basic_string -// __find +// __str_find template<class _CharT, class _SizeT, class _Traits, _SizeT __npos> _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY -__find(const _CharT *__p, _SizeT __sz, +__str_find(const _CharT *__p, _SizeT __sz, _CharT __c, _SizeT __pos) _NOEXCEPT { if (__pos >= __sz) @@ -1006,28 +1006,28 @@ __find(const _CharT *__p, _SizeT __sz, template<class _CharT, class _SizeT, class _Traits, _SizeT __npos> _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY -__find(const _CharT *__p, _SizeT __sz, +__str_find(const _CharT *__p, _SizeT __sz, const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT { if (__pos > __sz || __sz - __pos < __n) return __npos; if (__n == 0) return __pos; -// if (__n == 1) -// return _VSTD::__find<_CharT, _SizeT, _Traits, __npos>(__p, __sz, *__s, __pos); const _CharT* __r = - _VSTD::search(__p + __pos, __p + __sz, __s, __s + __n, _Traits::eq); + _VSTD::__search(__p + __pos, __p + __sz, + __s, __s + __n, _Traits::eq, + random_access_iterator_tag(), random_access_iterator_tag()); if (__r == __p + __sz) return __npos; return static_cast<_SizeT>(__r - __p); } -// __rfind +// __str_rfind template<class _CharT, class _SizeT, class _Traits, _SizeT __npos> _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY -__rfind(const _CharT *__p, _SizeT __sz, +__str_rfind(const _CharT *__p, _SizeT __sz, _CharT __c, _SizeT __pos) _NOEXCEPT { if (__sz < 1) @@ -1046,7 +1046,7 @@ __rfind(const _CharT *__p, _SizeT __sz, template<class _CharT, class _SizeT, class _Traits, _SizeT __npos> _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY -__rfind(const _CharT *__p, _SizeT __sz, +__str_rfind(const _CharT *__p, _SizeT __sz, const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT { __pos = _VSTD::min(__pos, __sz); @@ -1054,21 +1054,23 @@ __rfind(const _CharT *__p, _SizeT __sz, __pos += __n; else __pos = __sz; - const _CharT* __r = _VSTD::find_end(__p, __p + __pos, __s, __s + __n, _Traits::eq); + const _CharT* __r = _VSTD::__find_end( + __p, __p + __pos, __s, __s + __n, _Traits::eq, + random_access_iterator_tag(), random_access_iterator_tag()); if (__n > 0 && __r == __p + __pos) return __npos; return static_cast<_SizeT>(__r - __p); } -// __find_first_of +// __str_find_first_of template<class _CharT, class _SizeT, class _Traits, _SizeT __npos> _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY -__find_first_of(const _CharT *__p, _SizeT __sz, +__str_find_first_of(const _CharT *__p, _SizeT __sz, const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT { if (__pos >= __sz || __n == 0) return __npos; - const _CharT* __r = _VSTD::find_first_of + const _CharT* __r = _VSTD::__find_first_of_ce (__p + __pos, __p + __sz, __s, __s + __n, _Traits::eq ); if (__r == __p + __sz) return __npos; @@ -1076,10 +1078,10 @@ __find_first_of(const _CharT *__p, _SizeT __sz, } -// __find_last_of +// __str_find_last_of template<class _CharT, class _SizeT, class _Traits, _SizeT __npos> _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY -__find_last_of(const _CharT *__p, _SizeT __sz, +__str_find_last_of(const _CharT *__p, _SizeT __sz, const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT { if (__n != 0) @@ -1099,10 +1101,10 @@ __find_last_of(const _CharT *__p, _SizeT __sz, } -// __find_first_not_of +// __str_find_first_not_of template<class _CharT, class _SizeT, class _Traits, _SizeT __npos> _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY -__find_first_not_of(const _CharT *__p, _SizeT __sz, +__str_find_first_not_of(const _CharT *__p, _SizeT __sz, const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT { if (__pos < __sz) @@ -1118,7 +1120,7 @@ __find_first_not_of(const _CharT *__p, _SizeT __sz, template<class _CharT, class _SizeT, class _Traits, _SizeT __npos> _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY -__find_first_not_of(const _CharT *__p, _SizeT __sz, +__str_find_first_not_of(const _CharT *__p, _SizeT __sz, _CharT __c, _SizeT __pos) _NOEXCEPT { if (__pos < __sz) @@ -1132,10 +1134,10 @@ __find_first_not_of(const _CharT *__p, _SizeT __sz, } -// __find_last_not_of +// __str_find_last_not_of template<class _CharT, class _SizeT, class _Traits, _SizeT __npos> _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY -__find_last_not_of(const _CharT *__p, _SizeT __sz, +__str_find_last_not_of(const _CharT *__p, _SizeT __sz, const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT { if (__pos < __sz) @@ -1151,7 +1153,7 @@ __find_last_not_of(const _CharT *__p, _SizeT __sz, template<class _CharT, class _SizeT, class _Traits, _SizeT __npos> _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY -__find_last_not_of(const _CharT *__p, _SizeT __sz, +__str_find_last_not_of(const _CharT *__p, _SizeT __sz, _CharT __c, _SizeT __pos) _NOEXCEPT { if (__pos < __sz) @@ -3427,7 +3429,7 @@ basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s, size_type __n) const _NOEXCEPT { _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find(): received nullptr"); - return _VSTD::__find<value_type, size_type, traits_type, npos> + return _VSTD::__str_find<value_type, size_type, traits_type, npos> (data(), size(), __s, __pos, __n); } @@ -3437,7 +3439,7 @@ typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find(const basic_string& __str, size_type __pos) const _NOEXCEPT { - return _VSTD::__find<value_type, size_type, traits_type, npos> + return _VSTD::__str_find<value_type, size_type, traits_type, npos> (data(), size(), __str.data(), __pos, __str.size()); } @@ -3448,7 +3450,7 @@ basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s, size_type __pos) const _NOEXCEPT { _LIBCPP_ASSERT(__s != nullptr, "string::find(): received nullptr"); - return _VSTD::__find<value_type, size_type, traits_type, npos> + return _VSTD::__str_find<value_type, size_type, traits_type, npos> (data(), size(), __s, __pos, traits_type::length(__s)); } @@ -3457,7 +3459,7 @@ typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find(value_type __c, size_type __pos) const _NOEXCEPT { - return _VSTD::__find<value_type, size_type, traits_type, npos> + return _VSTD::__str_find<value_type, size_type, traits_type, npos> (data(), size(), __c, __pos); } @@ -3470,7 +3472,7 @@ basic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s, size_type __n) const _NOEXCEPT { _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::rfind(): received nullptr"); - return _VSTD::__rfind<value_type, size_type, traits_type, npos> + return _VSTD::__str_rfind<value_type, size_type, traits_type, npos> (data(), size(), __s, __pos, __n); } @@ -3480,7 +3482,7 @@ typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::rfind(const basic_string& __str, size_type __pos) const _NOEXCEPT { - return _VSTD::__rfind<value_type, size_type, traits_type, npos> + return _VSTD::__str_rfind<value_type, size_type, traits_type, npos> (data(), size(), __str.data(), __pos, __str.size()); } @@ -3491,7 +3493,7 @@ basic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s, size_type __pos) const _NOEXCEPT { _LIBCPP_ASSERT(__s != nullptr, "string::rfind(): received nullptr"); - return _VSTD::__rfind<value_type, size_type, traits_type, npos> + return _VSTD::__str_rfind<value_type, size_type, traits_type, npos> (data(), size(), __s, __pos, traits_type::length(__s)); } @@ -3500,7 +3502,7 @@ typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::rfind(value_type __c, size_type __pos) const _NOEXCEPT { - return _VSTD::__rfind<value_type, size_type, traits_type, npos> + return _VSTD::__str_rfind<value_type, size_type, traits_type, npos> (data(), size(), __c, __pos); } @@ -3513,7 +3515,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s, size_type __n) const _NOEXCEPT { _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_first_of(): received nullptr"); - return _VSTD::__find_first_of<value_type, size_type, traits_type, npos> + return _VSTD::__str_find_first_of<value_type, size_type, traits_type, npos> (data(), size(), __s, __pos, __n); } @@ -3523,7 +3525,7 @@ typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_first_of(const basic_string& __str, size_type __pos) const _NOEXCEPT { - return _VSTD::__find_first_of<value_type, size_type, traits_type, npos> + return _VSTD::__str_find_first_of<value_type, size_type, traits_type, npos> (data(), size(), __str.data(), __pos, __str.size()); } @@ -3534,7 +3536,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s, size_type __pos) const _NOEXCEPT { _LIBCPP_ASSERT(__s != nullptr, "string::find_first_of(): received nullptr"); - return _VSTD::__find_first_of<value_type, size_type, traits_type, npos> + return _VSTD::__str_find_first_of<value_type, size_type, traits_type, npos> (data(), size(), __s, __pos, traits_type::length(__s)); } @@ -3556,7 +3558,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s, size_type __n) const _NOEXCEPT { _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_last_of(): received nullptr"); - return _VSTD::__find_last_of<value_type, size_type, traits_type, npos> + return _VSTD::__str_find_last_of<value_type, size_type, traits_type, npos> (data(), size(), __s, __pos, __n); } @@ -3566,7 +3568,7 @@ typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_last_of(const basic_string& __str, size_type __pos) const _NOEXCEPT { - return _VSTD::__find_last_of<value_type, size_type, traits_type, npos> + return _VSTD::__str_find_last_of<value_type, size_type, traits_type, npos> (data(), size(), __str.data(), __pos, __str.size()); } @@ -3577,7 +3579,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s, size_type __pos) const _NOEXCEPT { _LIBCPP_ASSERT(__s != nullptr, "string::find_last_of(): received nullptr"); - return _VSTD::__find_last_of<value_type, size_type, traits_type, npos> + return _VSTD::__str_find_last_of<value_type, size_type, traits_type, npos> (data(), size(), __s, __pos, traits_type::length(__s)); } @@ -3599,7 +3601,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* _ size_type __n) const _NOEXCEPT { _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_first_not_of(): received nullptr"); - return _VSTD::__find_first_not_of<value_type, size_type, traits_type, npos> + return _VSTD::__str_find_first_not_of<value_type, size_type, traits_type, npos> (data(), size(), __s, __pos, __n); } @@ -3609,7 +3611,7 @@ typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const basic_string& __str, size_type __pos) const _NOEXCEPT { - return _VSTD::__find_first_not_of<value_type, size_type, traits_type, npos> + return _VSTD::__str_find_first_not_of<value_type, size_type, traits_type, npos> (data(), size(), __str.data(), __pos, __str.size()); } @@ -3620,7 +3622,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* _ size_type __pos) const _NOEXCEPT { _LIBCPP_ASSERT(__s != nullptr, "string::find_first_not_of(): received nullptr"); - return _VSTD::__find_first_not_of<value_type, size_type, traits_type, npos> + return _VSTD::__str_find_first_not_of<value_type, size_type, traits_type, npos> (data(), size(), __s, __pos, traits_type::length(__s)); } @@ -3630,7 +3632,7 @@ typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(value_type __c, size_type __pos) const _NOEXCEPT { - return _VSTD::__find_first_not_of<value_type, size_type, traits_type, npos> + return _VSTD::__str_find_first_not_of<value_type, size_type, traits_type, npos> (data(), size(), __c, __pos); } @@ -3643,7 +3645,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __ size_type __n) const _NOEXCEPT { _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_last_not_of(): received nullptr"); - return _VSTD::__find_last_not_of<value_type, size_type, traits_type, npos> + return _VSTD::__str_find_last_not_of<value_type, size_type, traits_type, npos> (data(), size(), __s, __pos, __n); } @@ -3653,7 +3655,7 @@ typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const basic_string& __str, size_type __pos) const _NOEXCEPT { - return _VSTD::__find_last_not_of<value_type, size_type, traits_type, npos> + return _VSTD::__str_find_last_not_of<value_type, size_type, traits_type, npos> (data(), size(), __str.data(), __pos, __str.size()); } @@ -3664,7 +3666,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __ size_type __pos) const _NOEXCEPT { _LIBCPP_ASSERT(__s != nullptr, "string::find_last_not_of(): received nullptr"); - return _VSTD::__find_last_not_of<value_type, size_type, traits_type, npos> + return _VSTD::__str_find_last_not_of<value_type, size_type, traits_type, npos> (data(), size(), __s, __pos, traits_type::length(__s)); } @@ -3674,7 +3676,7 @@ typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(value_type __c, size_type __pos) const _NOEXCEPT { - return _VSTD::__find_last_not_of<value_type, size_type, traits_type, npos> + return _VSTD::__str_find_last_not_of<value_type, size_type, traits_type, npos> (data(), size(), __c, __pos); } |