aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-12-02 12:47:11 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-12-02 12:47:11 +0000
commitdbabdb5220c44e5938d404eefb84b5ed55667ea8 (patch)
tree75c7e5204ae0564ac641b1629ef74066461d1884
parent8a86acebf859efb1adc46c88fa0cd69381a7291f (diff)
downloadsrc-dbabdb5220c44e5938d404eefb84b5ed55667ea8.tar.gz
src-dbabdb5220c44e5938d404eefb84b5ed55667ea8.zip
Notes
Notes: svn path=/vendor/libc++/dist/; revision=326465 svn path=/vendor/libc++/libc++-release_501-r320880/; revision=326904; tag=vendor/libc++/libc++-release_501-r320880
-rw-r--r--include/algorithm5
-rw-r--r--include/deque5
-rw-r--r--include/functional36
-rw-r--r--include/list13
-rw-r--r--include/string12
-rw-r--r--include/type_traits7
-rw-r--r--include/vector17
-rw-r--r--test/std/containers/sequences/deque/deque.cons/assign_iter_iter.pass.cpp53
-rw-r--r--test/std/containers/sequences/deque/deque.cons/iter_iter.pass.cpp51
-rw-r--r--test/std/containers/sequences/deque/deque.cons/iter_iter_alloc.pass.cpp53
-rw-r--r--test/std/containers/sequences/list/list.cons/input_iterator.pass.cpp182
-rw-r--r--test/std/containers/sequences/vector/vector.cons/assign_iter_iter.pass.cpp76
-rw-r--r--test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp157
-rw-r--r--test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp160
-rw-r--r--test/std/strings/basic.string/string.ops/string_compare/size_size_string_view.pass.cpp383
-rw-r--r--test/std/strings/basic.string/string.ops/string_compare/string_view.pass.cpp79
-rw-r--r--test/std/strings/basic.string/string.ops/string_find.first.not.of/string_view_size.pass.cpp159
-rw-r--r--test/std/strings/basic.string/string.ops/string_find.first.of/string_view_size.pass.cpp159
-rw-r--r--test/std/strings/basic.string/string.ops/string_find.last.not.of/string_view_size.pass.cpp159
-rw-r--r--test/std/strings/basic.string/string.ops/string_find.last.of/string_view_size.pass.cpp159
-rw-r--r--test/std/strings/basic.string/string.ops/string_find/string_view_size.pass.cpp159
-rw-r--r--test/std/strings/basic.string/string.ops/string_rfind/string_view_size.pass.cpp159
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_incomplete.pass.cpp37
-rw-r--r--test/support/container_test_types.h28
-rw-r--r--test/support/emplace_constructible.h74
25 files changed, 2274 insertions, 108 deletions
diff --git a/include/algorithm b/include/algorithm
index 4542275adfda..00db6d7e7c87 100644
--- a/include/algorithm
+++ b/include/algorithm
@@ -3013,6 +3013,7 @@ template<class _Engine, class _UIntType>
_UIntType
__independent_bits_engine<_Engine, _UIntType>::__eval(true_type)
{
+ const size_t _WRt = numeric_limits<result_type>::digits;
result_type _Sp = 0;
for (size_t __k = 0; __k < __n0_; ++__k)
{
@@ -3021,7 +3022,7 @@ __independent_bits_engine<_Engine, _UIntType>::__eval(true_type)
{
__u = __e_() - _Engine::min();
} while (__u >= __y0_);
- if (__w0_ < _WDt)
+ if (__w0_ < _WRt)
_Sp <<= __w0_;
else
_Sp = 0;
@@ -3034,7 +3035,7 @@ __independent_bits_engine<_Engine, _UIntType>::__eval(true_type)
{
__u = __e_() - _Engine::min();
} while (__u >= __y1_);
- if (__w0_ < _WDt - 1)
+ if (__w0_ < _WRt - 1)
_Sp <<= __w0_ + 1;
else
_Sp = 0;
diff --git a/include/deque b/include/deque
index f795b489edc6..fee75614b97f 100644
--- a/include/deque
+++ b/include/deque
@@ -1356,7 +1356,6 @@ public:
iterator insert(const_iterator __p, initializer_list<value_type> __il)
{return insert(__p, __il.begin(), __il.end());}
#endif // _LIBCPP_CXX03_LANG
-
iterator insert(const_iterator __p, const value_type& __v);
iterator insert(const_iterator __p, size_type __n, const value_type& __v);
template <class _InputIter>
@@ -2224,7 +2223,11 @@ deque<_Tp, _Allocator>::__append(_InpIter __f, _InpIter __l,
!__is_forward_iterator<_InpIter>::value>::type*)
{
for (; __f != __l; ++__f)
+#ifdef _LIBCPP_CXX03_LANG
push_back(*__f);
+#else
+ emplace_back(*__f);
+#endif
}
template <class _Tp, class _Allocator>
diff --git a/include/functional b/include/functional
index 83a2e5a39a88..f73c3ca56a8e 100644
--- a/include/functional
+++ b/include/functional
@@ -1597,9 +1597,11 @@ class _LIBCPP_TEMPLATE_VIS function<_Rp(_ArgTypes...)>
return reinterpret_cast<__base*>(p);
}
- template <class _Fp, bool = !is_same<_Fp, function>::value &&
- __invokable<_Fp&, _ArgTypes...>::value>
- struct __callable;
+ template <class _Fp, bool = __lazy_and<
+ integral_constant<bool, !is_same<__uncvref_t<_Fp>, function>::value>,
+ __invokable<_Fp&, _ArgTypes...>
+ >::value>
+ struct __callable;
template <class _Fp>
struct __callable<_Fp, true>
{
@@ -1612,6 +1614,9 @@ class _LIBCPP_TEMPLATE_VIS function<_Rp(_ArgTypes...)>
{
static const bool value = false;
};
+
+ template <class _Fp>
+ using _EnableIfCallable = typename enable_if<__callable<_Fp>::value>::type;
public:
typedef _Rp result_type;
@@ -1622,9 +1627,7 @@ public:
function(nullptr_t) _NOEXCEPT : __f_(0) {}
function(const function&);
function(function&&) _NOEXCEPT;
- template<class _Fp, class = typename enable_if<
- __callable<_Fp>::value && !is_same<_Fp, function>::value
- >::type>
+ template<class _Fp, class = _EnableIfCallable<_Fp>>
function(_Fp);
#if _LIBCPP_STD_VER <= 14
@@ -1638,21 +1641,15 @@ public:
function(allocator_arg_t, const _Alloc&, const function&);
template<class _Alloc>
function(allocator_arg_t, const _Alloc&, function&&);
- template<class _Fp, class _Alloc, class = typename enable_if<__callable<_Fp>::value>::type>
+ template<class _Fp, class _Alloc, class = _EnableIfCallable<_Fp>>
function(allocator_arg_t, const _Alloc& __a, _Fp __f);
#endif
function& operator=(const function&);
function& operator=(function&&) _NOEXCEPT;
function& operator=(nullptr_t) _NOEXCEPT;
- template<class _Fp>
- typename enable_if
- <
- __callable<typename decay<_Fp>::type>::value &&
- !is_same<typename remove_reference<_Fp>::type, function>::value,
- function&
- >::type
- operator=(_Fp&&);
+ template<class _Fp, class = _EnableIfCallable<_Fp>>
+ function& operator=(_Fp&&);
~function();
@@ -1854,13 +1851,8 @@ function<_Rp(_ArgTypes...)>::operator=(nullptr_t) _NOEXCEPT
}
template<class _Rp, class ..._ArgTypes>
-template <class _Fp>
-typename enable_if
-<
- function<_Rp(_ArgTypes...)>::template __callable<typename decay<_Fp>::type>::value &&
- !is_same<typename remove_reference<_Fp>::type, function<_Rp(_ArgTypes...)>>::value,
- function<_Rp(_ArgTypes...)>&
->::type
+template <class _Fp, class>
+function<_Rp(_ArgTypes...)>&
function<_Rp(_ArgTypes...)>::operator=(_Fp&& __f)
{
function(_VSTD::forward<_Fp>(__f)).swap(*this);
diff --git a/include/list b/include/list
index 20a66c36002d..9c70fff946c7 100644
--- a/include/list
+++ b/include/list
@@ -992,6 +992,15 @@ public:
void push_front(const value_type& __x);
void push_back(const value_type& __x);
+#ifndef _LIBCPP_CXX03_LANG
+ template <class _Arg>
+ _LIBCPP_INLINE_VISIBILITY
+ void __emplace_back(_Arg&& __arg) { emplace_back(_VSTD::forward<_Arg>(__arg)); }
+#else
+ _LIBCPP_INLINE_VISIBILITY
+ void __emplace_back(value_type const& __arg) { push_back(__arg); }
+#endif
+
iterator insert(const_iterator __p, const value_type& __x);
iterator insert(const_iterator __p, size_type __n, const value_type& __x);
template <class _InpIter>
@@ -1189,7 +1198,7 @@ list<_Tp, _Alloc>::list(_InpIter __f, _InpIter __l,
__get_db()->__insert_c(this);
#endif
for (; __f != __l; ++__f)
- push_back(*__f);
+ __emplace_back(*__f);
}
template <class _Tp, class _Alloc>
@@ -1202,7 +1211,7 @@ list<_Tp, _Alloc>::list(_InpIter __f, _InpIter __l, const allocator_type& __a,
__get_db()->__insert_c(this);
#endif
for (; __f != __l; ++__f)
- push_back(*__f);
+ __emplace_back(*__f);
}
template <class _Tp, class _Alloc>
diff --git a/include/string b/include/string
index 610f19ecba26..7775587a42d9 100644
--- a/include/string
+++ b/include/string
@@ -259,7 +259,7 @@ public:
size_type find(value_type c, size_type pos = 0) const noexcept;
size_type rfind(const basic_string& str, size_type pos = npos) const noexcept;
- size_type ffind(basic_string_view<charT, traits> sv, size_type pos = 0) const noexcept;
+ size_type rfind(basic_string_view<charT, traits> sv, size_type pos = npos) const noexcept;
size_type rfind(const value_type* s, size_type pos, size_type n) const noexcept;
size_type rfind(const value_type* s, size_type pos = npos) const noexcept;
size_type rfind(value_type c, size_type pos = npos) const noexcept;
@@ -271,7 +271,7 @@ public:
size_type find_first_of(value_type c, size_type pos = 0) const noexcept;
size_type find_last_of(const basic_string& str, size_type pos = npos) const noexcept;
- size_type find_last_of(basic_string_view<charT, traits> sv, size_type pos = 0) const noexcept;
+ size_type find_last_of(basic_string_view<charT, traits> sv, size_type pos = npos) const noexcept;
size_type find_last_of(const value_type* s, size_type pos, size_type n) const noexcept;
size_type find_last_of(const value_type* s, size_type pos = npos) const noexcept;
size_type find_last_of(value_type c, size_type pos = npos) const noexcept;
@@ -283,7 +283,7 @@ public:
size_type find_first_not_of(value_type c, size_type pos = 0) const noexcept;
size_type find_last_not_of(const basic_string& str, size_type pos = npos) const noexcept;
- size_type find_last_not_of(basic_string_view<charT, traits> sv, size_type pos = 0) const noexcept;
+ size_type find_last_not_of(basic_string_view<charT, traits> sv, size_type pos = npos) const noexcept;
size_type find_last_not_of(const value_type* s, size_type pos, size_type n) const noexcept;
size_type find_last_not_of(const value_type* s, size_type pos = npos) const noexcept;
size_type find_last_not_of(value_type c, size_type pos = npos) const noexcept;
@@ -1147,7 +1147,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
size_type rfind(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY
- size_type rfind(__self_view __sv, size_type __pos = 0) const _NOEXCEPT;
+ size_type rfind(__self_view __sv, size_type __pos = npos) const _NOEXCEPT;
size_type rfind(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY
size_type rfind(const value_type* __s, size_type __pos = npos) const _NOEXCEPT;
@@ -1166,7 +1166,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
size_type find_last_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY
- size_type find_last_of(__self_view __sv, size_type __pos = 0) const _NOEXCEPT;
+ size_type find_last_of(__self_view __sv, size_type __pos = npos) const _NOEXCEPT;
size_type find_last_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY
size_type find_last_of(const value_type* __s, size_type __pos = npos) const _NOEXCEPT;
@@ -1186,7 +1186,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
size_type find_last_not_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY
- size_type find_last_not_of(__self_view __sv, size_type __pos = 0) const _NOEXCEPT;
+ size_type find_last_not_of(__self_view __sv, size_type __pos = npos) const _NOEXCEPT;
size_type find_last_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY
size_type find_last_not_of(const value_type* __s, size_type __pos = npos) const _NOEXCEPT;
diff --git a/include/type_traits b/include/type_traits
index 9db4d66145fc..6c111abfd1e8 100644
--- a/include/type_traits
+++ b/include/type_traits
@@ -4339,8 +4339,8 @@ struct __invokable_r
using _Result = decltype(
_VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...));
- static const bool value =
- conditional<
+ using type =
+ typename conditional<
!is_same<_Result, __nat>::value,
typename conditional<
is_void<_Ret>::value,
@@ -4348,7 +4348,8 @@ struct __invokable_r
is_convertible<_Result, _Ret>
>::type,
false_type
- >::type::value;
+ >::type;
+ static const bool value = type::value;
};
template <class _Fp, class ..._Args>
diff --git a/include/vector b/include/vector
index 6e9920a0f80f..b2f8f092c63d 100644
--- a/include/vector
+++ b/include/vector
@@ -674,6 +674,17 @@ public:
const value_type* data() const _NOEXCEPT
{return _VSTD::__to_raw_pointer(this->__begin_);}
+#ifdef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ void __emplace_back(const value_type& __x) { push_back(__x); }
+#else
+ template <class _Arg>
+ _LIBCPP_INLINE_VISIBILITY
+ void __emplace_back(_Arg&& __arg) {
+ emplace_back(_VSTD::forward<_Arg>(__arg));
+ }
+#endif
+
_LIBCPP_INLINE_VISIBILITY void push_back(const_reference __x);
#ifndef _LIBCPP_CXX03_LANG
@@ -1128,7 +1139,7 @@ vector<_Tp, _Allocator>::vector(_InputIterator __first,
__get_db()->__insert_c(this);
#endif
for (; __first != __last; ++__first)
- push_back(*__first);
+ __emplace_back(*__first);
}
template <class _Tp, class _Allocator>
@@ -1145,7 +1156,7 @@ vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last, c
__get_db()->__insert_c(this);
#endif
for (; __first != __last; ++__first)
- push_back(*__first);
+ __emplace_back(*__first);
}
template <class _Tp, class _Allocator>
@@ -1365,7 +1376,7 @@ vector<_Tp, _Allocator>::assign(_InputIterator __first, _InputIterator __last)
{
clear();
for (; __first != __last; ++__first)
- push_back(*__first);
+ __emplace_back(*__first);
}
template <class _Tp, class _Allocator>
diff --git a/test/std/containers/sequences/deque/deque.cons/assign_iter_iter.pass.cpp b/test/std/containers/sequences/deque/deque.cons/assign_iter_iter.pass.cpp
index f06067786cfd..940d4e8d6815 100644
--- a/test/std/containers/sequences/deque/deque.cons/assign_iter_iter.pass.cpp
+++ b/test/std/containers/sequences/deque/deque.cons/assign_iter_iter.pass.cpp
@@ -19,6 +19,9 @@
#include "test_macros.h"
#include "test_iterators.h"
#include "min_allocator.h"
+#if TEST_STD_VER >= 11
+#include "emplace_constructible.h"
+#endif
template <class C>
C
@@ -80,7 +83,7 @@ testNI(int start, int N, int M)
testI(c1, c2);
}
-int main()
+void basic_test()
{
{
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
@@ -103,3 +106,51 @@ int main()
}
#endif
}
+
+void test_emplacable_concept() {
+#if TEST_STD_VER >= 11
+ int arr1[] = {42};
+ int arr2[] = {1, 101, 42};
+ {
+ using T = EmplaceConstructibleMoveableAndAssignable<int>;
+ using It = random_access_iterator<int*>;
+ {
+ std::deque<T> v;
+ v.assign(It(arr1), It(std::end(arr1)));
+ assert(v[0].value == 42);
+ }
+ {
+ std::deque<T> v;
+ v.assign(It(arr2), It(std::end(arr2)));
+ assert(v[0].value == 1);
+ assert(v[1].value == 101);
+ assert(v[2].value == 42);
+ }
+ }
+ {
+ using T = EmplaceConstructibleMoveableAndAssignable<int>;
+ using It = input_iterator<int*>;
+ {
+ std::deque<T> v;
+ v.assign(It(arr1), It(std::end(arr1)));
+ assert(v[0].copied == 0);
+ assert(v[0].value == 42);
+ }
+ {
+ std::deque<T> v;
+ v.assign(It(arr2), It(std::end(arr2)));
+ //assert(v[0].copied == 0);
+ assert(v[0].value == 1);
+ //assert(v[1].copied == 0);
+ assert(v[1].value == 101);
+ assert(v[2].copied == 0);
+ assert(v[2].value == 42);
+ }
+ }
+#endif
+}
+
+int main() {
+ basic_test();
+ test_emplacable_concept();
+}
diff --git a/test/std/containers/sequences/deque/deque.cons/iter_iter.pass.cpp b/test/std/containers/sequences/deque/deque.cons/iter_iter.pass.cpp
index 87445c5b2b67..793f2b12a2de 100644
--- a/test/std/containers/sequences/deque/deque.cons/iter_iter.pass.cpp
+++ b/test/std/containers/sequences/deque/deque.cons/iter_iter.pass.cpp
@@ -15,9 +15,13 @@
#include <cassert>
#include <cstddef>
+#include "test_macros.h"
#include "test_allocator.h"
#include "test_iterators.h"
#include "min_allocator.h"
+#if TEST_STD_VER >= 11
+#include "emplace_constructible.h"
+#endif
template <class InputIterator>
void
@@ -48,7 +52,7 @@ test(InputIterator f, InputIterator l)
assert(*i == *f);
}
-int main()
+void basic_test()
{
int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
int* an = ab + sizeof(ab)/sizeof(ab[0]);
@@ -61,3 +65,48 @@ int main()
test<min_allocator<int> >(ab, an);
#endif
}
+
+
+void test_emplacable_concept() {
+#if TEST_STD_VER >= 11
+ int arr1[] = {42};
+ int arr2[] = {1, 101, 42};
+ {
+ using T = EmplaceConstructibleAndMoveable<int>;
+ using It = random_access_iterator<int*>;
+ {
+ std::deque<T> v(It(arr1), It(std::end(arr1)));
+ assert(v[0].value == 42);
+ }
+ {
+ std::deque<T> v(It(arr2), It(std::end(arr2)));
+ assert(v[0].value == 1);
+ assert(v[1].value == 101);
+ assert(v[2].value == 42);
+ }
+ }
+ {
+ using T = EmplaceConstructibleAndMoveable<int>;
+ using It = input_iterator<int*>;
+ {
+ std::deque<T> v(It(arr1), It(std::end(arr1)));
+ assert(v[0].copied == 0);
+ assert(v[0].value == 42);
+ }
+ {
+ std::deque<T> v(It(arr2), It(std::end(arr2)));
+ //assert(v[0].copied == 0);
+ assert(v[0].value == 1);
+ //assert(v[1].copied == 0);
+ assert(v[1].value == 101);
+ assert(v[2].copied == 0);
+ assert(v[2].value == 42);
+ }
+ }
+#endif
+}
+
+int main() {
+ basic_test();
+ test_emplacable_concept();
+}
diff --git a/test/std/containers/sequences/deque/deque.cons/iter_iter_alloc.pass.cpp b/test/std/containers/sequences/deque/deque.cons/iter_iter_alloc.pass.cpp
index 54227ebc12d8..9ac342a8f767 100644
--- a/test/std/containers/sequences/deque/deque.cons/iter_iter_alloc.pass.cpp
+++ b/test/std/containers/sequences/deque/deque.cons/iter_iter_alloc.pass.cpp
@@ -16,9 +16,13 @@
#include <cassert>
#include <cstddef>
+#include "test_macros.h"
#include "test_iterators.h"
#include "test_allocator.h"
#include "min_allocator.h"
+#if TEST_STD_VER >= 11
+#include "emplace_constructible.h"
+#endif
template <class InputIterator, class Allocator>
void
@@ -35,7 +39,7 @@ test(InputIterator f, InputIterator l, const Allocator& a)
assert(*i == *f);
}
-int main()
+void basic_test()
{
int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
int* an = ab + sizeof(ab)/sizeof(ab[0]);
@@ -50,3 +54,50 @@ int main()
test(random_access_iterator<const int*>(ab), random_access_iterator<const int*>(an), min_allocator<int>());
#endif
}
+
+
+void test_emplacable_concept() {
+#if TEST_STD_VER >= 11
+ int arr1[] = {42};
+ int arr2[] = {1, 101, 42};
+ {
+ using T = EmplaceConstructibleAndMoveable<int>;
+ using It = random_access_iterator<int*>;
+ std::allocator<T> a;
+ {
+ std::deque<T> v(It(arr1), It(std::end(arr1)), a);
+ assert(v[0].value == 42);
+ }
+ {
+ std::deque<T> v(It(arr2), It(std::end(arr2)), a);
+ assert(v[0].value == 1);
+ assert(v[1].value == 101);
+ assert(v[2].value == 42);
+ }
+ }
+ {
+ using T = EmplaceConstructibleAndMoveable<int>;
+ using It = input_iterator<int*>;
+ std::allocator<T> a;
+ {
+ std::deque<T> v(It(arr1), It(std::end(arr1)), a);
+ assert(v[0].copied == 0);
+ assert(v[0].value == 42);
+ }
+ {
+ std::deque<T> v(It(arr2), It(std::end(arr2)), a);
+ //assert(v[0].copied == 0);
+ assert(v[0].value == 1);
+ //assert(v[1].copied == 0);
+ assert(v[1].value == 101);
+ assert(v[2].copied == 0);
+ assert(v[2].value == 42);
+ }
+ }
+#endif
+}
+
+int main() {
+ basic_test();
+ test_emplacable_concept();
+}
diff --git a/test/std/containers/sequences/list/list.cons/input_iterator.pass.cpp b/test/std/containers/sequences/list/list.cons/input_iterator.pass.cpp
index 3b3c2f7ef1ab..3cdcc73627b8 100644
--- a/test/std/containers/sequences/list/list.cons/input_iterator.pass.cpp
+++ b/test/std/containers/sequences/list/list.cons/input_iterator.pass.cpp
@@ -17,8 +17,12 @@
#include "test_iterators.h"
#include "test_allocator.h"
#include "min_allocator.h"
+#if TEST_STD_VER >= 11
+#include "emplace_constructible.h"
+#include "container_test_types.h"
+#endif
-int main()
+void basic_test()
{
{
int a[] = {0, 1, 2, 3};
@@ -76,3 +80,179 @@ int main()
}
#endif
}
+
+
+
+void test_emplacable_concept() {
+#if TEST_STD_VER >= 11
+ int arr1[] = {42};
+ int arr2[] = {1, 101, 42};
+ {
+ using T = EmplaceConstructible<int>;
+ using It = random_access_iterator<int*>;
+ {
+ std::list<T> v(It(arr1), It(std::end(arr1)));
+ auto I = v.begin();
+ assert(I->value == 42);
+ }
+ {
+ std::list<T> v(It(arr2), It(std::end(arr2)));
+ auto I = v.begin();
+ assert(I->value == 1);
+ ++I;
+ assert(I->value == 101);
+ ++I;
+ assert(I->value == 42);
+ }
+ }
+ {
+ using T = EmplaceConstructible<int>;
+ using It = input_iterator<int*>;
+ {
+ std::list<T> v(It(arr1), It(std::end(arr1)));
+ auto I = v.begin();
+ assert(I->value == 42);
+ }
+ {
+ std::list<T> v(It(arr2), It(std::end(arr2)));
+ auto I = v.begin();
+ //assert(v[0].copied == 0);
+ assert(I->value == 1);
+ //assert(v[1].copied == 0);
+ ++I;
+ assert(I->value == 101);
+ ++I;
+ assert(I->value == 42);
+ }
+ }
+#endif
+}
+
+
+
+void test_emplacable_concept_with_alloc() {
+#if TEST_STD_VER >= 11
+ int arr1[] = {42};
+ int arr2[] = {1, 101, 42};
+ {
+ using T = EmplaceConstructible<int>;
+ using It = random_access_iterator<int*>;
+ std::allocator<T> a;
+ {
+ std::list<T> v(It(arr1), It(std::end(arr1)), a);
+ auto I = v.begin();
+ assert(I->value == 42);
+ }
+ {
+ std::list<T> v(It(arr2), It(std::end(arr2)), a);
+ auto I = v.begin();
+ assert(I->value == 1);
+ ++I;
+ assert(I->value == 101);
+ ++I;
+ assert(I->value == 42);
+ }
+ }
+ {
+ using T = EmplaceConstructible<int>;
+ using It = input_iterator<int*>;
+ std::allocator<T> a;
+ {
+ std::list<T> v(It(arr1), It(std::end(arr1)), a);
+ auto I = v.begin();
+ assert(I->value == 42);
+ }
+ {
+ std::list<T> v(It(arr2), It(std::end(arr2)), a);
+ auto I = v.begin();
+ //assert(v[0].copied == 0);
+ assert(I->value == 1);
+ //assert(v[1].copied == 0);
+ ++I;
+ assert(I->value == 101);
+ ++I;
+ assert(I->value == 42);
+ }
+ }
+#endif
+}
+
+void test_ctor_under_alloc() {
+#if TEST_STD_VER >= 11
+ int arr1[] = {42};
+ int arr2[] = {1, 101, 42};
+ {
+ using C = TCT::list<>;
+ using T = typename C::value_type;
+ using It = forward_iterator<int*>;
+ {
+ ExpectConstructGuard<int&> G(1);
+ C v(It(arr1), It(std::end(arr1)));
+ }
+ {
+ ExpectConstructGuard<int&> G(3);
+ C v(It(arr2), It(std::end(arr2)));
+ }
+ }
+ {
+ using C = TCT::list<>;
+ using T = typename C::value_type;
+ using It = input_iterator<int*>;
+ {
+ ExpectConstructGuard<int&> G(1);
+ C v(It(arr1), It(std::end(arr1)));
+ }
+ {
+ ExpectConstructGuard<int&> G(3);
+ C v(It(arr2), It(std::end(arr2)));
+ }
+ }
+#endif
+}
+
+void test_ctor_under_alloc_with_alloc() {
+#if TEST_STD_VER >= 11
+ int arr1[] = {42};
+ int arr2[] = {1, 101, 42};
+ {
+ using C = TCT::list<>;
+ using T = typename C::value_type;
+ using It = forward_iterator<int*>;
+ using Alloc = typename C::allocator_type;
+ Alloc a;
+ {
+ ExpectConstructGuard<int&> G(1);
+ C v(It(arr1), It(std::end(arr1)), a);
+ }
+ {
+ ExpectConstructGuard<int&> G(3);
+ C v(It(arr2), It(std::end(arr2)), a);
+ }
+ }
+ {
+ using C = TCT::list<>;
+ using T = typename C::value_type;
+ using It = input_iterator<int*>;
+ using Alloc = typename C::allocator_type;
+ Alloc a;
+ {
+ ExpectConstructGuard<int&> G(1);
+ C v(It(arr1), It(std::end(arr1)), a);
+ }
+ {
+ ExpectConstructGuard<int&> G(3);
+ C v(It(arr2), It(std::end(arr2)), a);
+ }
+ }
+#endif
+}
+
+
+
+int main() {
+ basic_test();
+ test_emplacable_concept();
+ test_emplacable_concept_with_alloc();
+ test_ctor_under_alloc();
+ test_ctor_under_alloc_with_alloc();
+}
diff --git a/test/std/containers/sequences/vector/vector.cons/assign_iter_iter.pass.cpp b/test/std/containers/sequences/vector/vector.cons/assign_iter_iter.pass.cpp
new file mode 100644
index 000000000000..f07495637aa7
--- /dev/null
+++ b/test/std/containers/sequences/vector/vector.cons/assign_iter_iter.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// void assign(size_type n, const_reference v);
+
+#include <vector>
+#include <algorithm>
+#include <cassert>
+#include <iostream>
+#include "test_macros.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+#include "test_iterators.h"
+#if TEST_STD_VER >= 11
+#include "emplace_constructible.h"
+#include "container_test_types.h"
+#endif
+
+
+void test_emplaceable_concept() {
+#if TEST_STD_VER >= 11
+ int arr1[] = {42};
+ int arr2[] = {1, 101, 42};
+ {
+ using T = EmplaceConstructibleMoveableAndAssignable<int>;
+ using It = forward_iterator<int*>;
+ {
+ std::vector<T> v;
+ v.assign(It(arr1), It(std::end(arr1)));
+ assert(v[0].value == 42);
+ }
+ {
+ std::vector<T> v;
+ v.assign(It(arr2), It(std::end(arr2)));
+ assert(v[0].value == 1);
+ assert(v[1].value == 101);
+ assert(v[2].value == 42);
+ }
+ }
+ {
+ using T = EmplaceConstructibleMoveableAndAssignable<int>;
+ using It = input_iterator<int*>;
+ {
+ std::vector<T> v;
+ v.assign(It(arr1), It(std::end(arr1)));
+ assert(v[0].copied == 0);
+ assert(v[0].value == 42);
+ }
+ {
+ std::vector<T> v;
+ v.assign(It(arr2), It(std::end(arr2)));
+ //assert(v[0].copied == 0);
+ assert(v[0].value == 1);
+ //assert(v[1].copied == 0);
+ assert(v[1].value == 101);
+ assert(v[2].copied == 0);
+ assert(v[2].value == 42);
+ }
+ }
+#endif
+}
+
+
+
+int main()
+{
+ test_emplaceable_concept();
+}
diff --git a/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp b/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp
index ec4944d1ad1c..88613efe7a2b 100644
--- a/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp
+++ b/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp
@@ -20,40 +20,137 @@
#include "test_allocator.h"
#include "min_allocator.h"
#include "asan_testing.h"
+#if TEST_STD_VER >= 11
+#include "emplace_constructible.h"
+#include "container_test_types.h"
+#endif
template <class C, class Iterator>
-void
-test(Iterator first, Iterator last)
-{
- C c(first, last);
- LIBCPP_ASSERT(c.__invariants());
- assert(c.size() == static_cast<std::size_t>(std::distance(first, last)));
- LIBCPP_ASSERT(is_contiguous_container_asan_correct(c));
- for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i, ++first)
- assert(*i == *first);
+void test(Iterator first, Iterator last) {
+ C c(first, last);
+ LIBCPP_ASSERT(c.__invariants());
+ assert(c.size() == static_cast<std::size_t>(std::distance(first, last)));
+ LIBCPP_ASSERT(is_contiguous_container_asan_correct(c));
+ for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e;
+ ++i, ++first)
+ assert(*i == *first);
+}
+
+static void basic_test_cases() {
+ int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0};
+ int* an = a + sizeof(a) / sizeof(a[0]);
+ test<std::vector<int> >(input_iterator<const int*>(a),
+ input_iterator<const int*>(an));
+ test<std::vector<int> >(forward_iterator<const int*>(a),
+ forward_iterator<const int*>(an));
+ test<std::vector<int> >(bidirectional_iterator<const int*>(a),
+ bidirectional_iterator<const int*>(an));
+ test<std::vector<int> >(random_access_iterator<const int*>(a),
+ random_access_iterator<const int*>(an));
+ test<std::vector<int> >(a, an);
+
+ test<std::vector<int, limited_allocator<int, 63> > >(
+ input_iterator<const int*>(a), input_iterator<const int*>(an));
+ // Add 1 for implementations that dynamically allocate a container proxy.
+ test<std::vector<int, limited_allocator<int, 18 + 1> > >(
+ forward_iterator<const int*>(a), forward_iterator<const int*>(an));
+ test<std::vector<int, limited_allocator<int, 18 + 1> > >(
+ bidirectional_iterator<const int*>(a),
+ bidirectional_iterator<const int*>(an));
+ test<std::vector<int, limited_allocator<int, 18 + 1> > >(
+ random_access_iterator<const int*>(a),
+ random_access_iterator<const int*>(an));
+ test<std::vector<int, limited_allocator<int, 18 + 1> > >(a, an);
+#if TEST_STD_VER >= 11
+ test<std::vector<int, min_allocator<int> > >(input_iterator<const int*>(a),
+ input_iterator<const int*>(an));
+ test<std::vector<int, min_allocator<int> > >(
+ forward_iterator<const int*>(a), forward_iterator<const int*>(an));
+ test<std::vector<int, min_allocator<int> > >(
+ bidirectional_iterator<const int*>(a),
+ bidirectional_iterator<const int*>(an));
+ test<std::vector<int, min_allocator<int> > >(
+ random_access_iterator<const int*>(a),
+ random_access_iterator<const int*>(an));
+ test<std::vector<int> >(a, an);
+#endif
}
-int main()
-{
- int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0};
- int* an = a + sizeof(a)/sizeof(a[0]);
- test<std::vector<int> >(input_iterator<const int*>(a), input_iterator<const int*>(an));
- test<std::vector<int> >(forward_iterator<const int*>(a), forward_iterator<const int*>(an));
- test<std::vector<int> >(bidirectional_iterator<const int*>(a), bidirectional_iterator<const int*>(an));
- test<std::vector<int> >(random_access_iterator<const int*>(a), random_access_iterator<const int*>(an));
- test<std::vector<int> >(a, an);
-
- test<std::vector<int, limited_allocator<int, 63> > >(input_iterator<const int*>(a), input_iterator<const int*>(an));
- // Add 1 for implementations that dynamically allocate a container proxy.
- test<std::vector<int, limited_allocator<int, 18 + 1> > >(forward_iterator<const int*>(a), forward_iterator<const int*>(an));
- test<std::vector<int, limited_allocator<int, 18 + 1> > >(bidirectional_iterator<const int*>(a), bidirectional_iterator<const int*>(an));
- test<std::vector<int, limited_allocator<int, 18 + 1> > >(random_access_iterator<const int*>(a), random_access_iterator<const int*>(an));
- test<std::vector<int, limited_allocator<int, 18 + 1> > >(a, an);
+void emplaceable_concept_tests() {
#if TEST_STD_VER >= 11
- test<std::vector<int, min_allocator<int>> >(input_iterator<const int*>(a), input_iterator<const int*>(an));
- test<std::vector<int, min_allocator<int>> >(forward_iterator<const int*>(a), forward_iterator<const int*>(an));
- test<std::vector<int, min_allocator<int>> >(bidirectional_iterator<const int*>(a), bidirectional_iterator<const int*>(an));
- test<std::vector<int, min_allocator<int>> >(random_access_iterator<const int*>(a), random_access_iterator<const int*>(an));
- test<std::vector<int> >(a, an);
+ int arr1[] = {42};
+ int arr2[] = {1, 101, 42};
+ {
+ using T = EmplaceConstructible<int>;
+ using It = forward_iterator<int*>;
+ {
+ std::vector<T> v(It(arr1), It(std::end(arr1)));
+ assert(v[0].value == 42);
+ }
+ {
+ std::vector<T> v(It(arr2), It(std::end(arr2)));
+ assert(v[0].value == 1);
+ assert(v[1].value == 101);
+ assert(v[2].value == 42);
+ }
+ }
+ {
+ using T = EmplaceConstructibleAndMoveInsertable<int>;
+ using It = input_iterator<int*>;
+ {
+ std::vector<T> v(It(arr1), It(std::end(arr1)));
+ assert(v[0].copied == 0);
+ assert(v[0].value == 42);
+ }
+ {
+ std::vector<T> v(It(arr2), It(std::end(arr2)));
+ //assert(v[0].copied == 0);
+ assert(v[0].value == 1);
+ //assert(v[1].copied == 0);
+ assert(v[1].value == 101);
+ assert(v[2].copied == 0);
+ assert(v[2].value == 42);
+ }
+ }
#endif
}
+
+void test_ctor_under_alloc() {
+#if TEST_STD_VER >= 11
+ int arr1[] = {42};
+ int arr2[] = {1, 101, 42};
+ {
+ using C = TCT::vector<>;
+ using T = typename C::value_type;
+ using It = forward_iterator<int*>;
+ {
+ ExpectConstructGuard<int&> G(1);
+ C v(It(arr1), It(std::end(arr1)));
+ }
+ {
+ ExpectConstructGuard<int&> G(3);
+ C v(It(arr2), It(std::end(arr2)));
+ }
+ }
+ {
+ using C = TCT::vector<>;
+ using T = typename C::value_type;
+ using It = input_iterator<int*>;
+ {
+ ExpectConstructGuard<int&> G(1);
+ C v(It(arr1), It(std::end(arr1)));
+ }
+ {
+ //ExpectConstructGuard<int&> G(3);
+ //C v(It(arr2), It(std::end(arr2)), a);
+ }
+ }
+#endif
+}
+
+
+int main() {
+ basic_test_cases();
+ emplaceable_concept_tests(); // See PR34898
+ test_ctor_under_alloc();
+}
diff --git a/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp b/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp
index b4482ddb2727..71743b31d44c 100644
--- a/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp
+++ b/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp
@@ -21,56 +21,152 @@
#include "test_allocator.h"
#include "min_allocator.h"
#include "asan_testing.h"
+#if TEST_STD_VER >= 11
+#include "emplace_constructible.h"
+#include "container_test_types.h"
+#endif
template <class C, class Iterator, class A>
-void
-test(Iterator first, Iterator last, const A& a)
-{
- C c(first, last, a);
- LIBCPP_ASSERT(c.__invariants());
- assert(c.size() == static_cast<std::size_t>(std::distance(first, last)));
- LIBCPP_ASSERT(is_contiguous_container_asan_correct(c));
- for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i, ++first)
- assert(*i == *first);
+void test(Iterator first, Iterator last, const A& a) {
+ C c(first, last, a);
+ LIBCPP_ASSERT(c.__invariants());
+ assert(c.size() == static_cast<std::size_t>(std::distance(first, last)));
+ LIBCPP_ASSERT(is_contiguous_container_asan_correct(c));
+ for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e;
+ ++i, ++first)
+ assert(*i == *first);
}
#if TEST_STD_VER >= 11
template <class T>
-struct implicit_conv_allocator : min_allocator<T>
-{
- implicit_conv_allocator(void*) {}
- implicit_conv_allocator(const implicit_conv_allocator&) = default;
+struct implicit_conv_allocator : min_allocator<T> {
+ implicit_conv_allocator(void*) {}
+ implicit_conv_allocator(const implicit_conv_allocator&) = default;
- template <class U>
- implicit_conv_allocator(implicit_conv_allocator<U>) {}
+ template <class U>
+ implicit_conv_allocator(implicit_conv_allocator<U>) {}
};
#endif
-int main()
-{
- {
+void basic_tests() {
+ {
int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0};
- int* an = a + sizeof(a)/sizeof(a[0]);
+ int* an = a + sizeof(a) / sizeof(a[0]);
std::allocator<int> alloc;
- test<std::vector<int> >(input_iterator<const int*>(a), input_iterator<const int*>(an), alloc);
- test<std::vector<int> >(forward_iterator<const int*>(a), forward_iterator<const int*>(an), alloc);
- test<std::vector<int> >(bidirectional_iterator<const int*>(a), bidirectional_iterator<const int*>(an), alloc);
- test<std::vector<int> >(random_access_iterator<const int*>(a), random_access_iterator<const int*>(an), alloc);
+ test<std::vector<int> >(input_iterator<const int*>(a),
+ input_iterator<const int*>(an), alloc);
+ test<std::vector<int> >(forward_iterator<const int*>(a),
+ forward_iterator<const int*>(an), alloc);
+ test<std::vector<int> >(bidirectional_iterator<const int*>(a),
+ bidirectional_iterator<const int*>(an), alloc);
+ test<std::vector<int> >(random_access_iterator<const int*>(a),
+ random_access_iterator<const int*>(an), alloc);
test<std::vector<int> >(a, an, alloc);
- }
+ }
#if TEST_STD_VER >= 11
- {
+ {
int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0};
- int* an = a + sizeof(a)/sizeof(a[0]);
+ int* an = a + sizeof(a) / sizeof(a[0]);
min_allocator<int> alloc;
- test<std::vector<int, min_allocator<int>> >(input_iterator<const int*>(a), input_iterator<const int*>(an), alloc);
- test<std::vector<int, min_allocator<int>> >(forward_iterator<const int*>(a), forward_iterator<const int*>(an), alloc);
- test<std::vector<int, min_allocator<int>> >(bidirectional_iterator<const int*>(a), bidirectional_iterator<const int*>(an), alloc);
- test<std::vector<int, min_allocator<int>> >(random_access_iterator<const int*>(a), random_access_iterator<const int*>(an), alloc);
- test<std::vector<int, min_allocator<int>> >(a, an, alloc);
- test<std::vector<int, implicit_conv_allocator<int>> >(a, an, nullptr);
+ test<std::vector<int, min_allocator<int> > >(
+ input_iterator<const int*>(a), input_iterator<const int*>(an), alloc);
+ test<std::vector<int, min_allocator<int> > >(
+ forward_iterator<const int*>(a), forward_iterator<const int*>(an),
+ alloc);
+ test<std::vector<int, min_allocator<int> > >(
+ bidirectional_iterator<const int*>(a),
+ bidirectional_iterator<const int*>(an), alloc);
+ test<std::vector<int, min_allocator<int> > >(
+ random_access_iterator<const int*>(a),
+ random_access_iterator<const int*>(an), alloc);
+ test<std::vector<int, min_allocator<int> > >(a, an, alloc);
+ test<std::vector<int, implicit_conv_allocator<int> > >(a, an, nullptr);
+ }
+#endif
+}
+
+void emplaceable_concept_tests() {
+#if TEST_STD_VER >= 11
+ int arr1[] = {42};
+ int arr2[] = {1, 101, 42};
+ {
+ using T = EmplaceConstructible<int>;
+ using It = forward_iterator<int*>;
+ using Alloc = std::allocator<T>;
+ Alloc a;
+ {
+ std::vector<T> v(It(arr1), It(std::end(arr1)), a);
+ assert(v[0].value == 42);
+ }
+ {
+ std::vector<T> v(It(arr2), It(std::end(arr2)), a);
+ assert(v[0].value == 1);
+ assert(v[1].value == 101);
+ assert(v[2].value == 42);
+ }
+ }
+ {
+ using T = EmplaceConstructibleAndMoveInsertable<int>;
+ using It = input_iterator<int*>;
+ using Alloc = std::allocator<T>;
+ Alloc a;
+ {
+ std::vector<T> v(It(arr1), It(std::end(arr1)), a);
+ assert(v[0].copied == 0);
+ assert(v[0].value == 42);
+ }
+ {
+ std::vector<T> v(It(arr2), It(std::end(arr2)), a);
+ assert(v[0].value == 1);
+ assert(v[1].value == 101);
+ assert(v[2].copied == 0);
+ assert(v[2].value == 42);
}
+ }
#endif
}
+
+void test_ctor_under_alloc() {
+#if TEST_STD_VER >= 11
+ int arr1[] = {42};
+ int arr2[] = {1, 101, 42};
+ {
+ using C = TCT::vector<>;
+ using T = typename C::value_type;
+ using It = forward_iterator<int*>;
+ using Alloc = typename C::allocator_type;
+ Alloc a;
+ {
+ ExpectConstructGuard<int&> G(1);
+ C v(It(arr1), It(std::end(arr1)), a);
+ }
+ {
+ ExpectConstructGuard<int&> G(3);
+ C v(It(arr2), It(std::end(arr2)), a);
+ }
+ }
+ {
+ using C = TCT::vector<>;
+ using T = typename C::value_type;
+ using It = input_iterator<int*>;
+ using Alloc = typename C::allocator_type;
+ Alloc a;
+ {
+ ExpectConstructGuard<int&> G(1);
+ C v(It(arr1), It(std::end(arr1)), a);
+ }
+ {
+ //ExpectConstructGuard<int&> G(3);
+ //C v(It(arr2), It(std::end(arr2)), a);
+ }
+ }
+#endif
+}
+
+int main() {
+ basic_tests();
+ emplaceable_concept_tests(); // See PR34898
+ test_ctor_under_alloc();
+}
diff --git a/test/std/strings/basic.string/string.ops/string_compare/size_size_string_view.pass.cpp b/test/std/strings/basic.string/string.ops/string_compare/size_size_string_view.pass.cpp
new file mode 100644
index 000000000000..6a5ba22cdc8d
--- /dev/null
+++ b/test/std/strings/basic.string/string.ops/string_compare/size_size_string_view.pass.cpp
@@ -0,0 +1,383 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// int compare(size_type pos1, size_type n1, basic_string_vew sv) const;
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+#include "min_allocator.h"
+
+#include "test_macros.h"
+
+int sign(int x)
+{
+ if (x == 0)
+ return 0;
+ if (x < 0)
+ return -1;
+ return 1;
+}
+
+template <class S, class SV>
+void
+test(const S& s, typename S::size_type pos1, typename S::size_type n1,
+ SV sv, int x)
+{
+ if (pos1 <= s.size())
+ assert(sign(s.compare(pos1, n1, sv)) == sign(x));
+#ifndef TEST_HAS_NO_EXCEPTIONS
+ else
+ {
+ try
+ {
+ s.compare(pos1, n1, sv);
+ assert(false);
+ }
+ catch (std::out_of_range&)
+ {
+ assert(pos1 > s.size());
+ }
+ }
+#endif
+}
+
+template <class S, class SV>
+void test0()
+{
+ test(S(""), 0, 0, SV(""), 0);
+ test(S(""), 0, 0, SV("abcde"), -5);
+ test(S(""), 0, 0, SV("abcdefghij"), -10);
+ test(S(""), 0, 0, SV("abcdefghijklmnopqrst"), -20);
+ test(S(""), 0, 1, SV(""), 0);
+ test(S(""), 0, 1, SV("abcde"), -5);
+ test(S(""), 0, 1, SV("abcdefghij"), -10);
+ test(S(""), 0, 1, SV("abcdefghijklmnopqrst"), -20);
+ test(S(""), 1, 0, SV(""), 0);
+ test(S(""), 1, 0, SV("abcde"), 0);
+ test(S(""), 1, 0, SV("abcdefghij"), 0);
+ test(S(""), 1, 0, SV("abcdefghijklmnopqrst"), 0);
+ test(S("abcde"), 0, 0, SV(""), 0);
+ test(S("abcde"), 0, 0, SV("abcde"), -5);
+ test(S("abcde"), 0, 0, SV("abcdefghij"), -10);
+ test(S("abcde"), 0, 0, SV("abcdefghijklmnopqrst"), -20);
+ test(S("abcde"), 0, 1, SV(""), 1);
+ test(S("abcde"), 0, 1, SV("abcde"), -4);
+ test(S("abcde"), 0, 1, SV("abcdefghij"), -9);
+ test(S("abcde"), 0, 1, SV("abcdefghijklmnopqrst"), -19);
+ test(S("abcde"), 0, 2, SV(""), 2);
+ test(S("abcde"), 0, 2, SV("abcde"), -3);
+ test(S("abcde"), 0, 2, SV("abcdefghij"), -8);
+ test(S("abcde"), 0, 2, SV("abcdefghijklmnopqrst"), -18);
+ test(S("abcde"), 0, 4, SV(""), 4);
+ test(S("abcde"), 0, 4, SV("abcde"), -1);
+ test(S("abcde"), 0, 4, SV("abcdefghij"), -6);
+ test(S("abcde"), 0, 4, SV("abcdefghijklmnopqrst"), -16);
+ test(S("abcde"), 0, 5, SV(""), 5);
+ test(S("abcde"), 0, 5, SV("abcde"), 0);
+ test(S("abcde"), 0, 5, SV("abcdefghij"), -5);
+ test(S("abcde"), 0, 5, SV("abcdefghijklmnopqrst"), -15);
+ test(S("abcde"), 0, 6, SV(""), 5);
+ test(S("abcde"), 0, 6, SV("abcde"), 0);
+ test(S("abcde"), 0, 6, SV("abcdefghij"), -5);
+ test(S("abcde"), 0, 6, SV("abcdefghijklmnopqrst"), -15);
+ test(S("abcde"), 1, 0, SV(""), 0);
+ test(S("abcde"), 1, 0, SV("abcde"), -5);
+ test(S("abcde"), 1, 0, SV("abcdefghij"), -10);
+ test(S("abcde"), 1, 0, SV("abcdefghijklmnopqrst"), -20);
+ test(S("abcde"), 1, 1, SV(""), 1);
+ test(S("abcde"), 1, 1, SV("abcde"), 1);
+ test(S("abcde"), 1, 1, SV("abcdefghij"), 1);
+ test(S("abcde"), 1, 1, SV("abcdefghijklmnopqrst"), 1);
+ test(S("abcde"), 1, 2, SV(""), 2);
+ test(S("abcde"), 1, 2, SV("abcde"), 1);
+ test(S("abcde"), 1, 2, SV("abcdefghij"), 1);
+ test(S("abcde"), 1, 2, SV("abcdefghijklmnopqrst"), 1);
+ test(S("abcde"), 1, 3, SV(""), 3);
+ test(S("abcde"), 1, 3, SV("abcde"), 1);
+ test(S("abcde"), 1, 3, SV("abcdefghij"), 1);
+ test(S("abcde"), 1, 3, SV("abcdefghijklmnopqrst"), 1);
+ test(S("abcde"), 1, 4, SV(""), 4);
+ test(S("abcde"), 1, 4, SV("abcde"), 1);
+ test(S("abcde"), 1, 4, SV("abcdefghij"), 1);
+ test(S("abcde"), 1, 4, SV("abcdefghijklmnopqrst"), 1);
+ test(S("abcde"), 1, 5, SV(""), 4);
+ test(S("abcde"), 1, 5, SV("abcde"), 1);
+ test(S("abcde"), 1, 5, SV("abcdefghij"), 1);
+ test(S("abcde"), 1, 5, SV("abcdefghijklmnopqrst"), 1);
+ test(S("abcde"), 2, 0, SV(""), 0);
+ test(S("abcde"), 2, 0, SV("abcde"), -5);
+ test(S("abcde"), 2, 0, SV("abcdefghij"), -10);
+ test(S("abcde"), 2, 0, SV("abcdefghijklmnopqrst"), -20);
+ test(S("abcde"), 2, 1, SV(""), 1);
+ test(S("abcde"), 2, 1, SV("abcde"), 2);
+ test(S("abcde"), 2, 1, SV("abcdefghij"), 2);
+ test(S("abcde"), 2, 1, SV("abcdefghijklmnopqrst"), 2);
+ test(S("abcde"), 2, 2, SV(""), 2);
+ test(S("abcde"), 2, 2, SV("abcde"), 2);
+ test(S("abcde"), 2, 2, SV("abcdefghij"), 2);
+ test(S("abcde"), 2, 2, SV("abcdefghijklmnopqrst"), 2);
+ test(S("abcde"), 2, 3, SV(""), 3);
+ test(S("abcde"), 2, 3, SV("abcde"), 2);
+ test(S("abcde"), 2, 3, SV("abcdefghij"), 2);
+ test(S("abcde"), 2, 3, SV("abcdefghijklmnopqrst"), 2);
+ test(S("abcde"), 2, 4, SV(""), 3);
+ test(S("abcde"), 2, 4, SV("abcde"), 2);
+ test(S("abcde"), 2, 4, SV("abcdefghij"), 2);
+ test(S("abcde"), 2, 4, SV("abcdefghijklmnopqrst"), 2);
+ test(S("abcde"), 4, 0, SV(""), 0);
+ test(S("abcde"), 4, 0, SV("abcde"), -5);
+ test(S("abcde"), 4, 0, SV("abcdefghij"), -10);
+ test(S("abcde"), 4, 0, SV("abcdefghijklmnopqrst"), -20);
+ test(S("abcde"), 4, 1, SV(""), 1);
+ test(S("abcde"), 4, 1, SV("abcde"), 4);
+ test(S("abcde"), 4, 1, SV("abcdefghij"), 4);
+ test(S("abcde"), 4, 1, SV("abcdefghijklmnopqrst"), 4);
+ test(S("abcde"), 4, 2, SV(""), 1);
+ test(S("abcde"), 4, 2, SV("abcde"), 4);
+ test(S("abcde"), 4, 2, SV("abcdefghij"), 4);
+ test(S("abcde"), 4, 2, SV("abcdefghijklmnopqrst"), 4);
+ test(S("abcde"), 5, 0, SV(""), 0);
+ test(S("abcde"), 5, 0, SV("abcde"), -5);
+ test(S("abcde"), 5, 0, SV("abcdefghij"), -10);
+ test(S("abcde"), 5, 0, SV("abcdefghijklmnopqrst"), -20);
+ test(S("abcde"), 5, 1, SV(""), 0);
+ test(S("abcde"), 5, 1, SV("abcde"), -5);
+ test(S("abcde"), 5, 1, SV("abcdefghij"), -10);
+ test(S("abcde"), 5, 1, SV("abcdefghijklmnopqrst"), -20);
+}
+
+template <class S, class SV>
+void test1()
+{
+ test(S("abcde"), 6, 0, SV(""), 0);
+ test(S("abcde"), 6, 0, SV("abcde"), 0);
+ test(S("abcde"), 6, 0, SV("abcdefghij"), 0);
+ test(S("abcde"), 6, 0, SV("abcdefghijklmnopqrst"), 0);
+ test(S("abcdefghij"), 0, 0, SV(""), 0);
+ test(S("abcdefghij"), 0, 0, SV("abcde"), -5);
+ test(S("abcdefghij"), 0, 0, SV("abcdefghij"), -10);
+ test(S("abcdefghij"), 0, 0, SV("abcdefghijklmnopqrst"), -20);
+ test(S("abcdefghij"), 0, 1, SV(""), 1);
+ test(S("abcdefghij"), 0, 1, SV("abcde"), -4);
+ test(S("abcdefghij"), 0, 1, SV("abcdefghij"), -9);
+ test(S("abcdefghij"), 0, 1, SV("abcdefghijklmnopqrst"), -19);
+ test(S("abcdefghij"), 0, 5, SV(""), 5);
+ test(S("abcdefghij"), 0, 5, SV("abcde"), 0);
+ test(S("abcdefghij"), 0, 5, SV("abcdefghij"), -5);
+ test(S("abcdefghij"), 0, 5, SV("abcdefghijklmnopqrst"), -15);
+ test(S("abcdefghij"), 0, 9, SV(""), 9);
+ test(S("abcdefghij"), 0, 9, SV("abcde"), 4);
+ test(S("abcdefghij"), 0, 9, SV("abcdefghij"), -1);
+ test(S("abcdefghij"), 0, 9, SV("abcdefghijklmnopqrst"), -11);
+ test(S("abcdefghij"), 0, 10, SV(""), 10);
+ test(S("abcdefghij"), 0, 10, SV("abcde"), 5);
+ test(S("abcdefghij"), 0, 10, SV("abcdefghij"), 0);
+ test(S("abcdefghij"), 0, 10, SV("abcdefghijklmnopqrst"), -10);
+ test(S("abcdefghij"), 0, 11, SV(""), 10);
+ test(S("abcdefghij"), 0, 11, SV("abcde"), 5);
+ test(S("abcdefghij"), 0, 11, SV("abcdefghij"), 0);
+ test(S("abcdefghij"), 0, 11, SV("abcdefghijklmnopqrst"), -10);
+ test(S("abcdefghij"), 1, 0, SV(""), 0);
+ test(S("abcdefghij"), 1, 0, SV("abcde"), -5);
+ test(S("abcdefghij"), 1, 0, SV("abcdefghij"), -10);
+ test(S("abcdefghij"), 1, 0, SV("abcdefghijklmnopqrst"), -20);
+ test(S("abcdefghij"), 1, 1, SV(""), 1);
+ test(S("abcdefghij"), 1, 1, SV("abcde"), 1);
+ test(S("abcdefghij"), 1, 1, SV("abcdefghij"), 1);
+ test(S("abcdefghij"), 1, 1, SV("abcdefghijklmnopqrst"), 1);
+ test(S("abcdefghij"), 1, 4, SV(""), 4);
+ test(S("abcdefghij"), 1, 4, SV("abcde"), 1);
+ test(S("abcdefghij"), 1, 4, SV("abcdefghij"), 1);
+ test(S("abcdefghij"), 1, 4, SV("abcdefghijklmnopqrst"), 1);
+ test(S("abcdefghij"), 1, 8, SV(""), 8);
+ test(S("abcdefghij"), 1, 8, SV("abcde"), 1);
+ test(S("abcdefghij"), 1, 8, SV("abcdefghij"), 1);
+ test(S("abcdefghij"), 1, 8, SV("abcdefghijklmnopqrst"), 1);
+ test(S("abcdefghij"), 1, 9, SV(""), 9);
+ test(S("abcdefghij"), 1, 9, SV("abcde"), 1);
+ test(S("abcdefghij"), 1, 9, SV("abcdefghij"), 1);
+ test(S("abcdefghij"), 1, 9, SV("abcdefghijklmnopqrst"), 1);
+ test(S("abcdefghij"), 1, 10, SV(""), 9);
+ test(S("abcdefghij"), 1, 10, SV("abcde"), 1);
+ test(S("abcdefghij"), 1, 10, SV("abcdefghij"), 1);
+ test(S("abcdefghij"), 1, 10, SV("abcdefghijklmnopqrst"), 1);
+ test(S("abcdefghij"), 5, 0, SV(""), 0);
+ test(S("abcdefghij"), 5, 0, SV("abcde"), -5);
+ test(S("abcdefghij"), 5, 0, SV("abcdefghij"), -10);
+ test(S("abcdefghij"), 5, 0, SV("abcdefghijklmnopqrst"), -20);
+ test(S("abcdefghij"), 5, 1, SV(""), 1);
+ test(S("abcdefghij"), 5, 1, SV("abcde"), 5);
+ test(S("abcdefghij"), 5, 1, SV("abcdefghij"), 5);
+ test(S("abcdefghij"), 5, 1, SV("abcdefghijklmnopqrst"), 5);
+ test(S("abcdefghij"), 5, 2, SV(""), 2);
+ test(S("abcdefghij"), 5, 2, SV("abcde"), 5);
+ test(S("abcdefghij"), 5, 2, SV("abcdefghij"), 5);
+ test(S("abcdefghij"), 5, 2, SV("abcdefghijklmnopqrst"), 5);
+ test(S("abcdefghij"), 5, 4, SV(""), 4);
+ test(S("abcdefghij"), 5, 4, SV("abcde"), 5);
+ test(S("abcdefghij"), 5, 4, SV("abcdefghij"), 5);
+ test(S("abcdefghij"), 5, 4, SV("abcdefghijklmnopqrst"), 5);
+ test(S("abcdefghij"), 5, 5, SV(""), 5);
+ test(S("abcdefghij"), 5, 5, SV("abcde"), 5);
+ test(S("abcdefghij"), 5, 5, SV("abcdefghij"), 5);
+ test(S("abcdefghij"), 5, 5, SV("abcdefghijklmnopqrst"), 5);
+ test(S("abcdefghij"), 5, 6, SV(""), 5);
+ test(S("abcdefghij"), 5, 6, SV("abcde"), 5);
+ test(S("abcdefghij"), 5, 6, SV("abcdefghij"), 5);
+ test(S("abcdefghij"), 5, 6, SV("abcdefghijklmnopqrst"), 5);
+ test(S("abcdefghij"), 9, 0, SV(""), 0);
+ test(S("abcdefghij"), 9, 0, SV("abcde"), -5);
+ test(S("abcdefghij"), 9, 0, SV("abcdefghij"), -10);
+ test(S("abcdefghij"), 9, 0, SV("abcdefghijklmnopqrst"), -20);
+ test(S("abcdefghij"), 9, 1, SV(""), 1);
+ test(S("abcdefghij"), 9, 1, SV("abcde"), 9);
+ test(S("abcdefghij"), 9, 1, SV("abcdefghij"), 9);
+ test(S("abcdefghij"), 9, 1, SV("abcdefghijklmnopqrst"), 9);
+ test(S("abcdefghij"), 9, 2, SV(""), 1);
+ test(S("abcdefghij"), 9, 2, SV("abcde"), 9);
+ test(S("abcdefghij"), 9, 2, SV("abcdefghij"), 9);
+ test(S("abcdefghij"), 9, 2, SV("abcdefghijklmnopqrst"), 9);
+ test(S("abcdefghij"), 10, 0, SV(""), 0);
+ test(S("abcdefghij"), 10, 0, SV("abcde"), -5);
+ test(S("abcdefghij"), 10, 0, SV("abcdefghij"), -10);
+ test(S("abcdefghij"), 10, 0, SV("abcdefghijklmnopqrst"), -20);
+ test(S("abcdefghij"), 10, 1, SV(""), 0);
+ test(S("abcdefghij"), 10, 1, SV("abcde"), -5);
+ test(S("abcdefghij"), 10, 1, SV("abcdefghij"), -10);
+ test(S("abcdefghij"), 10, 1, SV("abcdefghijklmnopqrst"), -20);
+ test(S("abcdefghij"), 11, 0, SV(""), 0);
+ test(S("abcdefghij"), 11, 0, SV("abcde"), 0);
+ test(S("abcdefghij"), 11, 0, SV("abcdefghij"), 0);
+ test(S("abcdefghij"), 11, 0, SV("abcdefghijklmnopqrst"), 0);
+}
+
+template <class S, class SV>
+void test2()
+{
+ test(S("abcdefghijklmnopqrst"), 0, 0, SV(""), 0);
+ test(S("abcdefghijklmnopqrst"), 0, 0, SV("abcde"), -5);
+ test(S("abcdefghijklmnopqrst"), 0, 0, SV("abcdefghij"), -10);
+ test(S("abcdefghijklmnopqrst"), 0, 0, SV("abcdefghijklmnopqrst"), -20);
+ test(S("abcdefghijklmnopqrst"), 0, 1, SV(""), 1);
+ test(S("abcdefghijklmnopqrst"), 0, 1, SV("abcde"), -4);
+ test(S("abcdefghijklmnopqrst"), 0, 1, SV("abcdefghij"), -9);
+ test(S("abcdefghijklmnopqrst"), 0, 1, SV("abcdefghijklmnopqrst"), -19);
+ test(S("abcdefghijklmnopqrst"), 0, 10, SV(""), 10);
+ test(S("abcdefghijklmnopqrst"), 0, 10, SV("abcde"), 5);
+ test(S("abcdefghijklmnopqrst"), 0, 10, SV("abcdefghij"), 0);
+ test(S("abcdefghijklmnopqrst"), 0, 10, SV("abcdefghijklmnopqrst"), -10);
+ test(S("abcdefghijklmnopqrst"), 0, 19, SV(""), 19);
+ test(S("abcdefghijklmnopqrst"), 0, 19, SV("abcde"), 14);
+ test(S("abcdefghijklmnopqrst"), 0, 19, SV("abcdefghij"), 9);
+ test(S("abcdefghijklmnopqrst"), 0, 19, SV("abcdefghijklmnopqrst"), -1);
+ test(S("abcdefghijklmnopqrst"), 0, 20, SV(""), 20);
+ test(S("abcdefghijklmnopqrst"), 0, 20, SV("abcde"), 15);
+ test(S("abcdefghijklmnopqrst"), 0, 20, SV("abcdefghij"), 10);
+ test(S("abcdefghijklmnopqrst"), 0, 20, SV("abcdefghijklmnopqrst"), 0);
+ test(S("abcdefghijklmnopqrst"), 0, 21, SV(""), 20);
+ test(S("abcdefghijklmnopqrst"), 0, 21, SV("abcde"), 15);
+ test(S("abcdefghijklmnopqrst"), 0, 21, SV("abcdefghij"), 10);
+ test(S("abcdefghijklmnopqrst"), 0, 21, SV("abcdefghijklmnopqrst"), 0);
+ test(S("abcdefghijklmnopqrst"), 1, 0, SV(""), 0);
+ test(S("abcdefghijklmnopqrst"), 1, 0, SV("abcde"), -5);
+ test(S("abcdefghijklmnopqrst"), 1, 0, SV("abcdefghij"), -10);
+ test(S("abcdefghijklmnopqrst"), 1, 0, SV("abcdefghijklmnopqrst"), -20);
+ test(S("abcdefghijklmnopqrst"), 1, 1, SV(""), 1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, SV("abcde"), 1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, SV("abcdefghij"), 1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, SV("abcdefghijklmnopqrst"), 1);
+ test(S("abcdefghijklmnopqrst"), 1, 9, SV(""), 9);
+ test(S("abcdefghijklmnopqrst"), 1, 9, SV("abcde"), 1);
+ test(S("abcdefghijklmnopqrst"), 1, 9, SV("abcdefghij"), 1);
+ test(S("abcdefghijklmnopqrst"), 1, 9, SV("abcdefghijklmnopqrst"), 1);
+ test(S("abcdefghijklmnopqrst"), 1, 18, SV(""), 18);
+ test(S("abcdefghijklmnopqrst"), 1, 18, SV("abcde"), 1);
+ test(S("abcdefghijklmnopqrst"), 1, 18, SV("abcdefghij"), 1);
+ test(S("abcdefghijklmnopqrst"), 1, 18, SV("abcdefghijklmnopqrst"), 1);
+ test(S("abcdefghijklmnopqrst"), 1, 19, SV(""), 19);
+ test(S("abcdefghijklmnopqrst"), 1, 19, SV("abcde"), 1);
+ test(S("abcdefghijklmnopqrst"), 1, 19, SV("abcdefghij"), 1);
+ test(S("abcdefghijklmnopqrst"), 1, 19, SV("abcdefghijklmnopqrst"), 1);
+ test(S("abcdefghijklmnopqrst"), 1, 20, SV(""), 19);
+ test(S("abcdefghijklmnopqrst"), 1, 20, SV("abcde"), 1);
+ test(S("abcdefghijklmnopqrst"), 1, 20, SV("abcdefghij"), 1);
+ test(S("abcdefghijklmnopqrst"), 1, 20, SV("abcdefghijklmnopqrst"), 1);
+ test(S("abcdefghijklmnopqrst"), 10, 0, SV(""), 0);
+ test(S("abcdefghijklmnopqrst"), 10, 0, SV("abcde"), -5);
+ test(S("abcdefghijklmnopqrst"), 10, 0, SV("abcdefghij"), -10);
+ test(S("abcdefghijklmnopqrst"), 10, 0, SV("abcdefghijklmnopqrst"), -20);
+ test(S("abcdefghijklmnopqrst"), 10, 1, SV(""), 1);
+ test(S("abcdefghijklmnopqrst"), 10, 1, SV("abcde"), 10);
+ test(S("abcdefghijklmnopqrst"), 10, 1, SV("abcdefghij"), 10);
+ test(S("abcdefghijklmnopqrst"), 10, 1, SV("abcdefghijklmnopqrst"), 10);
+ test(S("abcdefghijklmnopqrst"), 10, 5, SV(""), 5);
+ test(S("abcdefghijklmnopqrst"), 10, 5, SV("abcde"), 10);
+ test(S("abcdefghijklmnopqrst"), 10, 5, SV("abcdefghij"), 10);
+ test(S("abcdefghijklmnopqrst"), 10, 5, SV("abcdefghijklmnopqrst"), 10);
+ test(S("abcdefghijklmnopqrst"), 10, 9, SV(""), 9);
+ test(S("abcdefghijklmnopqrst"), 10, 9, SV("abcde"), 10);
+ test(S("abcdefghijklmnopqrst"), 10, 9, SV("abcdefghij"), 10);
+ test(S("abcdefghijklmnopqrst"), 10, 9, SV("abcdefghijklmnopqrst"), 10);
+ test(S("abcdefghijklmnopqrst"), 10, 10, SV(""), 10);
+ test(S("abcdefghijklmnopqrst"), 10, 10, SV("abcde"), 10);
+ test(S("abcdefghijklmnopqrst"), 10, 10, SV("abcdefghij"), 10);
+ test(S("abcdefghijklmnopqrst"), 10, 10, SV("abcdefghijklmnopqrst"), 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, SV(""), 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, SV("abcde"), 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, SV("abcdefghij"), 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, SV("abcdefghijklmnopqrst"), 10);
+ test(S("abcdefghijklmnopqrst"), 19, 0, SV(""), 0);
+ test(S("abcdefghijklmnopqrst"), 19, 0, SV("abcde"), -5);
+ test(S("abcdefghijklmnopqrst"), 19, 0, SV("abcdefghij"), -10);
+ test(S("abcdefghijklmnopqrst"), 19, 0, SV("abcdefghijklmnopqrst"), -20);
+ test(S("abcdefghijklmnopqrst"), 19, 1, SV(""), 1);
+ test(S("abcdefghijklmnopqrst"), 19, 1, SV("abcde"), 19);
+ test(S("abcdefghijklmnopqrst"), 19, 1, SV("abcdefghij"), 19);
+ test(S("abcdefghijklmnopqrst"), 19, 1, SV("abcdefghijklmnopqrst"), 19);
+ test(S("abcdefghijklmnopqrst"), 19, 2, SV(""), 1);
+ test(S("abcdefghijklmnopqrst"), 19, 2, SV("abcde"), 19);
+ test(S("abcdefghijklmnopqrst"), 19, 2, SV("abcdefghij"), 19);
+ test(S("abcdefghijklmnopqrst"), 19, 2, SV("abcdefghijklmnopqrst"), 19);
+ test(S("abcdefghijklmnopqrst"), 20, 0, SV(""), 0);
+ test(S("abcdefghijklmnopqrst"), 20, 0, SV("abcde"), -5);
+ test(S("abcdefghijklmnopqrst"), 20, 0, SV("abcdefghij"), -10);
+ test(S("abcdefghijklmnopqrst"), 20, 0, SV("abcdefghijklmnopqrst"), -20);
+ test(S("abcdefghijklmnopqrst"), 20, 1, SV(""), 0);
+ test(S("abcdefghijklmnopqrst"), 20, 1, SV("abcde"), -5);
+ test(S("abcdefghijklmnopqrst"), 20, 1, SV("abcdefghij"), -10);
+ test(S("abcdefghijklmnopqrst"), 20, 1, SV("abcdefghijklmnopqrst"), -20);
+ test(S("abcdefghijklmnopqrst"), 21, 0, SV(""), 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, SV("abcde"), 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, SV("abcdefghij"), 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, SV("abcdefghijklmnopqrst"), 0);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ typedef std::string_view SV;
+ test0<S, SV>();
+ test1<S, SV>();
+ test2<S, SV>();
+ }
+#if TEST_STD_VER >= 11
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ typedef std::string_view SV;
+ test0<S, SV>();
+ test1<S, SV>();
+ test2<S, SV>();
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.ops/string_compare/string_view.pass.cpp b/test/std/strings/basic.string/string.ops/string_compare/string_view.pass.cpp
new file mode 100644
index 000000000000..8f0d48884d74
--- /dev/null
+++ b/test/std/strings/basic.string/string.ops/string_compare/string_view.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// int compare(const basic_string_view sv) const
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int sign(int x)
+{
+ if (x == 0)
+ return 0;
+ if (x < 0)
+ return -1;
+ return 1;
+}
+
+template <class S, class SV>
+void
+test(const S& s, SV sv, int x)
+{
+ assert(sign(s.compare(sv)) == sign(x));
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ typedef std::string_view SV;
+ test(S(""), SV(""), 0);
+ test(S(""), SV("abcde"), -5);
+ test(S(""), SV("abcdefghij"), -10);
+ test(S(""), SV("abcdefghijklmnopqrst"), -20);
+ test(S("abcde"), SV(""), 5);
+ test(S("abcde"), SV("abcde"), 0);
+ test(S("abcde"), SV("abcdefghij"), -5);
+ test(S("abcde"), SV("abcdefghijklmnopqrst"), -15);
+ test(S("abcdefghij"), SV(""), 10);
+ test(S("abcdefghij"), SV("abcde"), 5);
+ test(S("abcdefghij"), SV("abcdefghij"), 0);
+ test(S("abcdefghij"), SV("abcdefghijklmnopqrst"), -10);
+ test(S("abcdefghijklmnopqrst"), SV(""), 20);
+ test(S("abcdefghijklmnopqrst"), SV("abcde"), 15);
+ test(S("abcdefghijklmnopqrst"), SV("abcdefghij"), 10);
+ test(S("abcdefghijklmnopqrst"), SV("abcdefghijklmnopqrst"), 0);
+ }
+#if TEST_STD_VER >= 11
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ typedef std::string_view SV;
+ test(S(""), SV(""), 0);
+ test(S(""), SV("abcde"), -5);
+ test(S(""), SV("abcdefghij"), -10);
+ test(S(""), SV("abcdefghijklmnopqrst"), -20);
+ test(S("abcde"), SV(""), 5);
+ test(S("abcde"), SV("abcde"), 0);
+ test(S("abcde"), SV("abcdefghij"), -5);
+ test(S("abcde"), SV("abcdefghijklmnopqrst"), -15);
+ test(S("abcdefghij"), SV(""), 10);
+ test(S("abcdefghij"), SV("abcde"), 5);
+ test(S("abcdefghij"), SV("abcdefghij"), 0);
+ test(S("abcdefghij"), SV("abcdefghijklmnopqrst"), -10);
+ test(S("abcdefghijklmnopqrst"), SV(""), 20);
+ test(S("abcdefghijklmnopqrst"), SV("abcde"), 15);
+ test(S("abcdefghijklmnopqrst"), SV("abcdefghij"), 10);
+ test(S("abcdefghijklmnopqrst"), SV("abcdefghijklmnopqrst"), 0);
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.ops/string_find.first.not.of/string_view_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_find.first.not.of/string_view_size.pass.cpp
new file mode 100644
index 000000000000..fb69f8b3410f
--- /dev/null
+++ b/test/std/strings/basic.string/string.ops/string_find.first.not.of/string_view_size.pass.cpp
@@ -0,0 +1,159 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find_first_not_of(basic_string_view sv, size_type pos = 0) const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S, class SV>
+void
+test(const S& s, SV sv, typename S::size_type pos, typename S::size_type x)
+{
+ assert(s.find_first_not_of(sv, pos) == x);
+ if (x != S::npos)
+ assert(pos <= x && x < s.size());
+}
+
+template <class S, class SV>
+void
+test(const S& s, SV sv, typename S::size_type x)
+{
+ assert(s.find_first_not_of(sv) == x);
+ if (x != S::npos)
+ assert(x < s.size());
+}
+
+template <class S, class SV>
+void test0()
+{
+ test(S(""), SV(""), 0, S::npos);
+ test(S(""), SV("laenf"), 0, S::npos);
+ test(S(""), SV("pqlnkmbdjo"), 0, S::npos);
+ test(S(""), SV("qkamfogpnljdcshbreti"), 0, S::npos);
+ test(S(""), SV(""), 1, S::npos);
+ test(S(""), SV("bjaht"), 1, S::npos);
+ test(S(""), SV("hjlcmgpket"), 1, S::npos);
+ test(S(""), SV("htaobedqikfplcgjsmrn"), 1, S::npos);
+ test(S("fodgq"), SV(""), 0, 0);
+ test(S("qanej"), SV("dfkap"), 0, 0);
+ test(S("clbao"), SV("ihqrfebgad"), 0, 0);
+ test(S("mekdn"), SV("ngtjfcalbseiqrphmkdo"), 0, S::npos);
+ test(S("srdfq"), SV(""), 1, 1);
+ test(S("oemth"), SV("ikcrq"), 1, 1);
+ test(S("cdaih"), SV("dmajblfhsg"), 1, 3);
+ test(S("qohtk"), SV("oqftjhdmkgsblacenirp"), 1, S::npos);
+ test(S("cshmd"), SV(""), 2, 2);
+ test(S("lhcdo"), SV("oebqi"), 2, 2);
+ test(S("qnsoh"), SV("kojhpmbsfe"), 2, S::npos);
+ test(S("pkrof"), SV("acbsjqogpltdkhinfrem"), 2, S::npos);
+ test(S("fmtsp"), SV(""), 4, 4);
+ test(S("khbpm"), SV("aobjd"), 4, 4);
+ test(S("pbsji"), SV("pcbahntsje"), 4, 4);
+ test(S("mprdj"), SV("fhepcrntkoagbmldqijs"), 4, S::npos);
+ test(S("eqmpa"), SV(""), 5, S::npos);
+ test(S("omigs"), SV("kocgb"), 5, S::npos);
+ test(S("onmje"), SV("fbslrjiqkm"), 5, S::npos);
+ test(S("oqmrj"), SV("jeidpcmalhfnqbgtrsko"), 5, S::npos);
+ test(S("schfa"), SV(""), 6, S::npos);
+ test(S("igdsc"), SV("qngpd"), 6, S::npos);
+ test(S("brqgo"), SV("rodhqklgmb"), 6, S::npos);
+ test(S("tnrph"), SV("thdjgafrlbkoiqcspmne"), 6, S::npos);
+ test(S("hcjitbfapl"), SV(""), 0, 0);
+ test(S("daiprenocl"), SV("ashjd"), 0, 2);
+ test(S("litpcfdghe"), SV("mgojkldsqh"), 0, 1);
+ test(S("aidjksrolc"), SV("imqnaghkfrdtlopbjesc"), 0, S::npos);
+ test(S("qpghtfbaji"), SV(""), 1, 1);
+ test(S("gfshlcmdjr"), SV("nadkh"), 1, 1);
+ test(S("nkodajteqp"), SV("ofdrqmkebl"), 1, 4);
+ test(S("gbmetiprqd"), SV("bdfjqgatlksriohemnpc"), 1, S::npos);
+ test(S("crnklpmegd"), SV(""), 5, 5);
+ test(S("jsbtafedoc"), SV("prqgn"), 5, 5);
+ test(S("qnmodrtkeb"), SV("pejafmnokr"), 5, 6);
+ test(S("cpebqsfmnj"), SV("odnqkgijrhabfmcestlp"), 5, S::npos);
+ test(S("lmofqdhpki"), SV(""), 9, 9);
+ test(S("hnefkqimca"), SV("rtjpa"), 9, S::npos);
+ test(S("drtasbgmfp"), SV("ktsrmnqagd"), 9, 9);
+ test(S("lsaijeqhtr"), SV("rtdhgcisbnmoaqkfpjle"), 9, S::npos);
+ test(S("elgofjmbrq"), SV(""), 10, S::npos);
+ test(S("mjqdgalkpc"), SV("dplqa"), 10, S::npos);
+ test(S("kthqnfcerm"), SV("dkacjoptns"), 10, S::npos);
+ test(S("dfsjhanorc"), SV("hqfimtrgnbekpdcsjalo"), 10, S::npos);
+ test(S("eqsgalomhb"), SV(""), 11, S::npos);
+ test(S("akiteljmoh"), SV("lofbc"), 11, S::npos);
+ test(S("hlbdfreqjo"), SV("astoegbfpn"), 11, S::npos);
+ test(S("taqobhlerg"), SV("pdgreqomsncafklhtibj"), 11, S::npos);
+ test(S("snafbdlghrjkpqtoceim"), SV(""), 0, 0);
+ test(S("aemtbrgcklhndjisfpoq"), SV("lbtqd"), 0, 0);
+ test(S("pnracgfkjdiholtbqsem"), SV("tboimldpjh"), 0, 1);
+ test(S("dicfltehbsgrmojnpkaq"), SV("slcerthdaiqjfnobgkpm"), 0, S::npos);
+ test(S("jlnkraeodhcspfgbqitm"), SV(""), 1, 1);
+ test(S("lhosrngtmfjikbqpcade"), SV("aqibs"), 1, 1);
+ test(S("rbtaqjhgkneisldpmfoc"), SV("gtfblmqinc"), 1, 3);
+ test(S("gpifsqlrdkbonjtmheca"), SV("mkqpbtdalgniorhfescj"), 1, S::npos);
+ test(S("hdpkobnsalmcfijregtq"), SV(""), 10, 10);
+ test(S("jtlshdgqaiprkbcoenfm"), SV("pblas"), 10, 11);
+ test(S("fkdrbqltsgmcoiphneaj"), SV("arosdhcfme"), 10, 13);
+ test(S("crsplifgtqedjohnabmk"), SV("blkhjeogicatqfnpdmsr"), 10, S::npos);
+ test(S("niptglfbosehkamrdqcj"), SV(""), 19, 19);
+ test(S("copqdhstbingamjfkler"), SV("djkqc"), 19, 19);
+ test(S("mrtaefilpdsgocnhqbjk"), SV("lgokshjtpb"), 19, S::npos);
+ test(S("kojatdhlcmigpbfrqnes"), SV("bqjhtkfepimcnsgrlado"), 19, S::npos);
+ test(S("eaintpchlqsbdgrkjofm"), SV(""), 20, S::npos);
+ test(S("gjnhidfsepkrtaqbmclo"), SV("nocfa"), 20, S::npos);
+ test(S("spocfaktqdbiejlhngmr"), SV("bgtajmiedc"), 20, S::npos);
+ test(S("rphmlekgfscndtaobiqj"), SV("lsckfnqgdahejiopbtmr"), 20, S::npos);
+ test(S("liatsqdoegkmfcnbhrpj"), SV(""), 21, S::npos);
+ test(S("binjagtfldkrspcomqeh"), SV("gfsrt"), 21, S::npos);
+ test(S("latkmisecnorjbfhqpdg"), SV("pfsocbhjtm"), 21, S::npos);
+ test(S("lecfratdjkhnsmqpoigb"), SV("tpflmdnoicjgkberhqsa"), 21, S::npos);
+}
+
+template <class S, class SV>
+void test1()
+{
+ test(S(""), SV(""), S::npos);
+ test(S(""), SV("laenf"), S::npos);
+ test(S(""), SV("pqlnkmbdjo"), S::npos);
+ test(S(""), SV("qkamfogpnljdcshbreti"), S::npos);
+ test(S("nhmko"), SV(""), 0);
+ test(S("lahfb"), SV("irkhs"), 0);
+ test(S("gmfhd"), SV("kantesmpgj"), 2);
+ test(S("odaft"), SV("oknlrstdpiqmjbaghcfe"), S::npos);
+ test(S("eolhfgpjqk"), SV(""), 0);
+ test(S("nbatdlmekr"), SV("bnrpe"), 2);
+ test(S("jdmciepkaq"), SV("jtdaefblso"), 2);
+ test(S("hkbgspoflt"), SV("oselktgbcapndfjihrmq"), S::npos);
+ test(S("gprdcokbnjhlsfmtieqa"), SV(""), 0);
+ test(S("qjghlnftcaismkropdeb"), SV("bjaht"), 0);
+ test(S("pnalfrdtkqcmojiesbhg"), SV("hjlcmgpket"), 1);
+ test(S("pniotcfrhqsmgdkjbael"), SV("htaobedqikfplcgjsmrn"), S::npos);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ typedef std::string_view SV;
+ test0<S, SV>();
+ test1<S, SV>();
+ }
+#if TEST_STD_VER >= 11
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ typedef std::string_view SV;
+ test0<S, SV>();
+ test1<S, SV>();
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.ops/string_find.first.of/string_view_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_find.first.of/string_view_size.pass.cpp
new file mode 100644
index 000000000000..05925afaa6cd
--- /dev/null
+++ b/test/std/strings/basic.string/string.ops/string_find.first.of/string_view_size.pass.cpp
@@ -0,0 +1,159 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find_first_of(const basic_string_view sv, size_type pos = 0) const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S, class SV>
+void
+test(const S& s, SV sv, typename S::size_type pos, typename S::size_type x)
+{
+ assert(s.find_first_of(sv, pos) == x);
+ if (x != S::npos)
+ assert(pos <= x && x < s.size());
+}
+
+template <class S, class SV>
+void
+test(const S& s, SV sv, typename S::size_type x)
+{
+ assert(s.find_first_of(sv) == x);
+ if (x != S::npos)
+ assert(x < s.size());
+}
+
+template <class S, class SV>
+void test0()
+{
+ test(S(""), SV(""), 0, S::npos);
+ test(S(""), SV("laenf"), 0, S::npos);
+ test(S(""), SV("pqlnkmbdjo"), 0, S::npos);
+ test(S(""), SV("qkamfogpnljdcshbreti"), 0, S::npos);
+ test(S(""), SV(""), 1, S::npos);
+ test(S(""), SV("bjaht"), 1, S::npos);
+ test(S(""), SV("hjlcmgpket"), 1, S::npos);
+ test(S(""), SV("htaobedqikfplcgjsmrn"), 1, S::npos);
+ test(S("fodgq"), SV(""), 0, S::npos);
+ test(S("qanej"), SV("dfkap"), 0, 1);
+ test(S("clbao"), SV("ihqrfebgad"), 0, 2);
+ test(S("mekdn"), SV("ngtjfcalbseiqrphmkdo"), 0, 0);
+ test(S("srdfq"), SV(""), 1, S::npos);
+ test(S("oemth"), SV("ikcrq"), 1, S::npos);
+ test(S("cdaih"), SV("dmajblfhsg"), 1, 1);
+ test(S("qohtk"), SV("oqftjhdmkgsblacenirp"), 1, 1);
+ test(S("cshmd"), SV(""), 2, S::npos);
+ test(S("lhcdo"), SV("oebqi"), 2, 4);
+ test(S("qnsoh"), SV("kojhpmbsfe"), 2, 2);
+ test(S("pkrof"), SV("acbsjqogpltdkhinfrem"), 2, 2);
+ test(S("fmtsp"), SV(""), 4, S::npos);
+ test(S("khbpm"), SV("aobjd"), 4, S::npos);
+ test(S("pbsji"), SV("pcbahntsje"), 4, S::npos);
+ test(S("mprdj"), SV("fhepcrntkoagbmldqijs"), 4, 4);
+ test(S("eqmpa"), SV(""), 5, S::npos);
+ test(S("omigs"), SV("kocgb"), 5, S::npos);
+ test(S("onmje"), SV("fbslrjiqkm"), 5, S::npos);
+ test(S("oqmrj"), SV("jeidpcmalhfnqbgtrsko"), 5, S::npos);
+ test(S("schfa"), SV(""), 6, S::npos);
+ test(S("igdsc"), SV("qngpd"), 6, S::npos);
+ test(S("brqgo"), SV("rodhqklgmb"), 6, S::npos);
+ test(S("tnrph"), SV("thdjgafrlbkoiqcspmne"), 6, S::npos);
+ test(S("hcjitbfapl"), SV(""), 0, S::npos);
+ test(S("daiprenocl"), SV("ashjd"), 0, 0);
+ test(S("litpcfdghe"), SV("mgojkldsqh"), 0, 0);
+ test(S("aidjksrolc"), SV("imqnaghkfrdtlopbjesc"), 0, 0);
+ test(S("qpghtfbaji"), SV(""), 1, S::npos);
+ test(S("gfshlcmdjr"), SV("nadkh"), 1, 3);
+ test(S("nkodajteqp"), SV("ofdrqmkebl"), 1, 1);
+ test(S("gbmetiprqd"), SV("bdfjqgatlksriohemnpc"), 1, 1);
+ test(S("crnklpmegd"), SV(""), 5, S::npos);
+ test(S("jsbtafedoc"), SV("prqgn"), 5, S::npos);
+ test(S("qnmodrtkeb"), SV("pejafmnokr"), 5, 5);
+ test(S("cpebqsfmnj"), SV("odnqkgijrhabfmcestlp"), 5, 5);
+ test(S("lmofqdhpki"), SV(""), 9, S::npos);
+ test(S("hnefkqimca"), SV("rtjpa"), 9, 9);
+ test(S("drtasbgmfp"), SV("ktsrmnqagd"), 9, S::npos);
+ test(S("lsaijeqhtr"), SV("rtdhgcisbnmoaqkfpjle"), 9, 9);
+ test(S("elgofjmbrq"), SV(""), 10, S::npos);
+ test(S("mjqdgalkpc"), SV("dplqa"), 10, S::npos);
+ test(S("kthqnfcerm"), SV("dkacjoptns"), 10, S::npos);
+ test(S("dfsjhanorc"), SV("hqfimtrgnbekpdcsjalo"), 10, S::npos);
+ test(S("eqsgalomhb"), SV(""), 11, S::npos);
+ test(S("akiteljmoh"), SV("lofbc"), 11, S::npos);
+ test(S("hlbdfreqjo"), SV("astoegbfpn"), 11, S::npos);
+ test(S("taqobhlerg"), SV("pdgreqomsncafklhtibj"), 11, S::npos);
+ test(S("snafbdlghrjkpqtoceim"), SV(""), 0, S::npos);
+ test(S("aemtbrgcklhndjisfpoq"), SV("lbtqd"), 0, 3);
+ test(S("pnracgfkjdiholtbqsem"), SV("tboimldpjh"), 0, 0);
+ test(S("dicfltehbsgrmojnpkaq"), SV("slcerthdaiqjfnobgkpm"), 0, 0);
+ test(S("jlnkraeodhcspfgbqitm"), SV(""), 1, S::npos);
+ test(S("lhosrngtmfjikbqpcade"), SV("aqibs"), 1, 3);
+ test(S("rbtaqjhgkneisldpmfoc"), SV("gtfblmqinc"), 1, 1);
+ test(S("gpifsqlrdkbonjtmheca"), SV("mkqpbtdalgniorhfescj"), 1, 1);
+ test(S("hdpkobnsalmcfijregtq"), SV(""), 10, S::npos);
+ test(S("jtlshdgqaiprkbcoenfm"), SV("pblas"), 10, 10);
+ test(S("fkdrbqltsgmcoiphneaj"), SV("arosdhcfme"), 10, 10);
+ test(S("crsplifgtqedjohnabmk"), SV("blkhjeogicatqfnpdmsr"), 10, 10);
+ test(S("niptglfbosehkamrdqcj"), SV(""), 19, S::npos);
+ test(S("copqdhstbingamjfkler"), SV("djkqc"), 19, S::npos);
+ test(S("mrtaefilpdsgocnhqbjk"), SV("lgokshjtpb"), 19, 19);
+ test(S("kojatdhlcmigpbfrqnes"), SV("bqjhtkfepimcnsgrlado"), 19, 19);
+ test(S("eaintpchlqsbdgrkjofm"), SV(""), 20, S::npos);
+ test(S("gjnhidfsepkrtaqbmclo"), SV("nocfa"), 20, S::npos);
+ test(S("spocfaktqdbiejlhngmr"), SV("bgtajmiedc"), 20, S::npos);
+ test(S("rphmlekgfscndtaobiqj"), SV("lsckfnqgdahejiopbtmr"), 20, S::npos);
+ test(S("liatsqdoegkmfcnbhrpj"), SV(""), 21, S::npos);
+ test(S("binjagtfldkrspcomqeh"), SV("gfsrt"), 21, S::npos);
+ test(S("latkmisecnorjbfhqpdg"), SV("pfsocbhjtm"), 21, S::npos);
+ test(S("lecfratdjkhnsmqpoigb"), SV("tpflmdnoicjgkberhqsa"), 21, S::npos);
+}
+
+template <class S, class SV>
+void test1()
+{
+ test(S(""), SV(""), S::npos);
+ test(S(""), SV("laenf"), S::npos);
+ test(S(""), SV("pqlnkmbdjo"), S::npos);
+ test(S(""), SV("qkamfogpnljdcshbreti"), S::npos);
+ test(S("nhmko"), SV(""), S::npos);
+ test(S("lahfb"), SV("irkhs"), 2);
+ test(S("gmfhd"), SV("kantesmpgj"), 0);
+ test(S("odaft"), SV("oknlrstdpiqmjbaghcfe"), 0);
+ test(S("eolhfgpjqk"), SV(""), S::npos);
+ test(S("nbatdlmekr"), SV("bnrpe"), 0);
+ test(S("jdmciepkaq"), SV("jtdaefblso"), 0);
+ test(S("hkbgspoflt"), SV("oselktgbcapndfjihrmq"), 0);
+ test(S("gprdcokbnjhlsfmtieqa"), SV(""), S::npos);
+ test(S("qjghlnftcaismkropdeb"), SV("bjaht"), 1);
+ test(S("pnalfrdtkqcmojiesbhg"), SV("hjlcmgpket"), 0);
+ test(S("pniotcfrhqsmgdkjbael"), SV("htaobedqikfplcgjsmrn"), 0);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ typedef std::string_view SV;
+ test0<S, SV>();
+ test1<S, SV>();
+ }
+#if TEST_STD_VER >= 11
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ typedef std::string_view SV;
+ test0<S, SV>();
+ test1<S, SV>();
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.ops/string_find.last.not.of/string_view_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_find.last.not.of/string_view_size.pass.cpp
new file mode 100644
index 000000000000..59d216df09b4
--- /dev/null
+++ b/test/std/strings/basic.string/string.ops/string_find.last.not.of/string_view_size.pass.cpp
@@ -0,0 +1,159 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find_last_not_of(basic_string_view sv, size_type pos = npos) const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S, class SV>
+void
+test(const S& s, SV sv, typename S::size_type pos, typename S::size_type x)
+{
+ assert(s.find_last_not_of(sv, pos) == x);
+ if (x != S::npos)
+ assert(x <= pos && x < s.size());
+}
+
+template <class S, class SV>
+void
+test(const S& s, SV sv, typename S::size_type x)
+{
+ assert(s.find_last_not_of(sv) == x);
+ if (x != S::npos)
+ assert(x < s.size());
+}
+
+template <class S, class SV>
+void test0()
+{
+ test(S(""), SV(""), 0, S::npos);
+ test(S(""), SV("laenf"), 0, S::npos);
+ test(S(""), SV("pqlnkmbdjo"), 0, S::npos);
+ test(S(""), SV("qkamfogpnljdcshbreti"), 0, S::npos);
+ test(S(""), SV(""), 1, S::npos);
+ test(S(""), SV("bjaht"), 1, S::npos);
+ test(S(""), SV("hjlcmgpket"), 1, S::npos);
+ test(S(""), SV("htaobedqikfplcgjsmrn"), 1, S::npos);
+ test(S("fodgq"), SV(""), 0, 0);
+ test(S("qanej"), SV("dfkap"), 0, 0);
+ test(S("clbao"), SV("ihqrfebgad"), 0, 0);
+ test(S("mekdn"), SV("ngtjfcalbseiqrphmkdo"), 0, S::npos);
+ test(S("srdfq"), SV(""), 1, 1);
+ test(S("oemth"), SV("ikcrq"), 1, 1);
+ test(S("cdaih"), SV("dmajblfhsg"), 1, 0);
+ test(S("qohtk"), SV("oqftjhdmkgsblacenirp"), 1, S::npos);
+ test(S("cshmd"), SV(""), 2, 2);
+ test(S("lhcdo"), SV("oebqi"), 2, 2);
+ test(S("qnsoh"), SV("kojhpmbsfe"), 2, 1);
+ test(S("pkrof"), SV("acbsjqogpltdkhinfrem"), 2, S::npos);
+ test(S("fmtsp"), SV(""), 4, 4);
+ test(S("khbpm"), SV("aobjd"), 4, 4);
+ test(S("pbsji"), SV("pcbahntsje"), 4, 4);
+ test(S("mprdj"), SV("fhepcrntkoagbmldqijs"), 4, S::npos);
+ test(S("eqmpa"), SV(""), 5, 4);
+ test(S("omigs"), SV("kocgb"), 5, 4);
+ test(S("onmje"), SV("fbslrjiqkm"), 5, 4);
+ test(S("oqmrj"), SV("jeidpcmalhfnqbgtrsko"), 5, S::npos);
+ test(S("schfa"), SV(""), 6, 4);
+ test(S("igdsc"), SV("qngpd"), 6, 4);
+ test(S("brqgo"), SV("rodhqklgmb"), 6, S::npos);
+ test(S("tnrph"), SV("thdjgafrlbkoiqcspmne"), 6, S::npos);
+ test(S("hcjitbfapl"), SV(""), 0, 0);
+ test(S("daiprenocl"), SV("ashjd"), 0, S::npos);
+ test(S("litpcfdghe"), SV("mgojkldsqh"), 0, S::npos);
+ test(S("aidjksrolc"), SV("imqnaghkfrdtlopbjesc"), 0, S::npos);
+ test(S("qpghtfbaji"), SV(""), 1, 1);
+ test(S("gfshlcmdjr"), SV("nadkh"), 1, 1);
+ test(S("nkodajteqp"), SV("ofdrqmkebl"), 1, 0);
+ test(S("gbmetiprqd"), SV("bdfjqgatlksriohemnpc"), 1, S::npos);
+ test(S("crnklpmegd"), SV(""), 5, 5);
+ test(S("jsbtafedoc"), SV("prqgn"), 5, 5);
+ test(S("qnmodrtkeb"), SV("pejafmnokr"), 5, 4);
+ test(S("cpebqsfmnj"), SV("odnqkgijrhabfmcestlp"), 5, S::npos);
+ test(S("lmofqdhpki"), SV(""), 9, 9);
+ test(S("hnefkqimca"), SV("rtjpa"), 9, 8);
+ test(S("drtasbgmfp"), SV("ktsrmnqagd"), 9, 9);
+ test(S("lsaijeqhtr"), SV("rtdhgcisbnmoaqkfpjle"), 9, S::npos);
+ test(S("elgofjmbrq"), SV(""), 10, 9);
+ test(S("mjqdgalkpc"), SV("dplqa"), 10, 9);
+ test(S("kthqnfcerm"), SV("dkacjoptns"), 10, 9);
+ test(S("dfsjhanorc"), SV("hqfimtrgnbekpdcsjalo"), 10, S::npos);
+ test(S("eqsgalomhb"), SV(""), 11, 9);
+ test(S("akiteljmoh"), SV("lofbc"), 11, 9);
+ test(S("hlbdfreqjo"), SV("astoegbfpn"), 11, 8);
+ test(S("taqobhlerg"), SV("pdgreqomsncafklhtibj"), 11, S::npos);
+ test(S("snafbdlghrjkpqtoceim"), SV(""), 0, 0);
+ test(S("aemtbrgcklhndjisfpoq"), SV("lbtqd"), 0, 0);
+ test(S("pnracgfkjdiholtbqsem"), SV("tboimldpjh"), 0, S::npos);
+ test(S("dicfltehbsgrmojnpkaq"), SV("slcerthdaiqjfnobgkpm"), 0, S::npos);
+ test(S("jlnkraeodhcspfgbqitm"), SV(""), 1, 1);
+ test(S("lhosrngtmfjikbqpcade"), SV("aqibs"), 1, 1);
+ test(S("rbtaqjhgkneisldpmfoc"), SV("gtfblmqinc"), 1, 0);
+ test(S("gpifsqlrdkbonjtmheca"), SV("mkqpbtdalgniorhfescj"), 1, S::npos);
+ test(S("hdpkobnsalmcfijregtq"), SV(""), 10, 10);
+ test(S("jtlshdgqaiprkbcoenfm"), SV("pblas"), 10, 9);
+ test(S("fkdrbqltsgmcoiphneaj"), SV("arosdhcfme"), 10, 9);
+ test(S("crsplifgtqedjohnabmk"), SV("blkhjeogicatqfnpdmsr"), 10, S::npos);
+ test(S("niptglfbosehkamrdqcj"), SV(""), 19, 19);
+ test(S("copqdhstbingamjfkler"), SV("djkqc"), 19, 19);
+ test(S("mrtaefilpdsgocnhqbjk"), SV("lgokshjtpb"), 19, 16);
+ test(S("kojatdhlcmigpbfrqnes"), SV("bqjhtkfepimcnsgrlado"), 19, S::npos);
+ test(S("eaintpchlqsbdgrkjofm"), SV(""), 20, 19);
+ test(S("gjnhidfsepkrtaqbmclo"), SV("nocfa"), 20, 18);
+ test(S("spocfaktqdbiejlhngmr"), SV("bgtajmiedc"), 20, 19);
+ test(S("rphmlekgfscndtaobiqj"), SV("lsckfnqgdahejiopbtmr"), 20, S::npos);
+ test(S("liatsqdoegkmfcnbhrpj"), SV(""), 21, 19);
+ test(S("binjagtfldkrspcomqeh"), SV("gfsrt"), 21, 19);
+ test(S("latkmisecnorjbfhqpdg"), SV("pfsocbhjtm"), 21, 19);
+ test(S("lecfratdjkhnsmqpoigb"), SV("tpflmdnoicjgkberhqsa"), 21, S::npos);
+}
+
+template <class S, class SV>
+void test1()
+{
+ test(S(""), SV(""), S::npos);
+ test(S(""), SV("laenf"), S::npos);
+ test(S(""), SV("pqlnkmbdjo"), S::npos);
+ test(S(""), SV("qkamfogpnljdcshbreti"), S::npos);
+ test(S("nhmko"), SV(""), 4);
+ test(S("lahfb"), SV("irkhs"), 4);
+ test(S("gmfhd"), SV("kantesmpgj"), 4);
+ test(S("odaft"), SV("oknlrstdpiqmjbaghcfe"), S::npos);
+ test(S("eolhfgpjqk"), SV(""), 9);
+ test(S("nbatdlmekr"), SV("bnrpe"), 8);
+ test(S("jdmciepkaq"), SV("jtdaefblso"), 9);
+ test(S("hkbgspoflt"), SV("oselktgbcapndfjihrmq"), S::npos);
+ test(S("gprdcokbnjhlsfmtieqa"), SV(""), 19);
+ test(S("qjghlnftcaismkropdeb"), SV("bjaht"), 18);
+ test(S("pnalfrdtkqcmojiesbhg"), SV("hjlcmgpket"), 17);
+ test(S("pniotcfrhqsmgdkjbael"), SV("htaobedqikfplcgjsmrn"), S::npos);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ typedef std::string_view SV;
+ test0<S, SV>();
+ test1<S, SV>();
+ }
+#if TEST_STD_VER >= 11
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ typedef std::string_view SV;
+// test0<S, SV>();
+// test1<S, SV>();
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.ops/string_find.last.of/string_view_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_find.last.of/string_view_size.pass.cpp
new file mode 100644
index 000000000000..fb8ca34417a3
--- /dev/null
+++ b/test/std/strings/basic.string/string.ops/string_find.last.of/string_view_size.pass.cpp
@@ -0,0 +1,159 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find_last_of(const basic_string_view sv, size_type pos = npos) const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S, class SV>
+void
+test(const S& s, SV sv, typename S::size_type pos, typename S::size_type x)
+{
+ assert(s.find_last_of(sv, pos) == x);
+ if (x != S::npos)
+ assert(x <= pos && x < s.size());
+}
+
+template <class S, class SV>
+void
+test(const S& s, SV sv, typename S::size_type x)
+{
+ assert(s.find_last_of(sv) == x);
+ if (x != S::npos)
+ assert(x < s.size());
+}
+
+template <class S, class SV>
+void test0()
+{
+ test(S(""), SV(""), 0, S::npos);
+ test(S(""), SV("laenf"), 0, S::npos);
+ test(S(""), SV("pqlnkmbdjo"), 0, S::npos);
+ test(S(""), SV("qkamfogpnljdcshbreti"), 0, S::npos);
+ test(S(""), SV(""), 1, S::npos);
+ test(S(""), SV("bjaht"), 1, S::npos);
+ test(S(""), SV("hjlcmgpket"), 1, S::npos);
+ test(S(""), SV("htaobedqikfplcgjsmrn"), 1, S::npos);
+ test(S("fodgq"), SV(""), 0, S::npos);
+ test(S("qanej"), SV("dfkap"), 0, S::npos);
+ test(S("clbao"), SV("ihqrfebgad"), 0, S::npos);
+ test(S("mekdn"), SV("ngtjfcalbseiqrphmkdo"), 0, 0);
+ test(S("srdfq"), SV(""), 1, S::npos);
+ test(S("oemth"), SV("ikcrq"), 1, S::npos);
+ test(S("cdaih"), SV("dmajblfhsg"), 1, 1);
+ test(S("qohtk"), SV("oqftjhdmkgsblacenirp"), 1, 1);
+ test(S("cshmd"), SV(""), 2, S::npos);
+ test(S("lhcdo"), SV("oebqi"), 2, S::npos);
+ test(S("qnsoh"), SV("kojhpmbsfe"), 2, 2);
+ test(S("pkrof"), SV("acbsjqogpltdkhinfrem"), 2, 2);
+ test(S("fmtsp"), SV(""), 4, S::npos);
+ test(S("khbpm"), SV("aobjd"), 4, 2);
+ test(S("pbsji"), SV("pcbahntsje"), 4, 3);
+ test(S("mprdj"), SV("fhepcrntkoagbmldqijs"), 4, 4);
+ test(S("eqmpa"), SV(""), 5, S::npos);
+ test(S("omigs"), SV("kocgb"), 5, 3);
+ test(S("onmje"), SV("fbslrjiqkm"), 5, 3);
+ test(S("oqmrj"), SV("jeidpcmalhfnqbgtrsko"), 5, 4);
+ test(S("schfa"), SV(""), 6, S::npos);
+ test(S("igdsc"), SV("qngpd"), 6, 2);
+ test(S("brqgo"), SV("rodhqklgmb"), 6, 4);
+ test(S("tnrph"), SV("thdjgafrlbkoiqcspmne"), 6, 4);
+ test(S("hcjitbfapl"), SV(""), 0, S::npos);
+ test(S("daiprenocl"), SV("ashjd"), 0, 0);
+ test(S("litpcfdghe"), SV("mgojkldsqh"), 0, 0);
+ test(S("aidjksrolc"), SV("imqnaghkfrdtlopbjesc"), 0, 0);
+ test(S("qpghtfbaji"), SV(""), 1, S::npos);
+ test(S("gfshlcmdjr"), SV("nadkh"), 1, S::npos);
+ test(S("nkodajteqp"), SV("ofdrqmkebl"), 1, 1);
+ test(S("gbmetiprqd"), SV("bdfjqgatlksriohemnpc"), 1, 1);
+ test(S("crnklpmegd"), SV(""), 5, S::npos);
+ test(S("jsbtafedoc"), SV("prqgn"), 5, S::npos);
+ test(S("qnmodrtkeb"), SV("pejafmnokr"), 5, 5);
+ test(S("cpebqsfmnj"), SV("odnqkgijrhabfmcestlp"), 5, 5);
+ test(S("lmofqdhpki"), SV(""), 9, S::npos);
+ test(S("hnefkqimca"), SV("rtjpa"), 9, 9);
+ test(S("drtasbgmfp"), SV("ktsrmnqagd"), 9, 7);
+ test(S("lsaijeqhtr"), SV("rtdhgcisbnmoaqkfpjle"), 9, 9);
+ test(S("elgofjmbrq"), SV(""), 10, S::npos);
+ test(S("mjqdgalkpc"), SV("dplqa"), 10, 8);
+ test(S("kthqnfcerm"), SV("dkacjoptns"), 10, 6);
+ test(S("dfsjhanorc"), SV("hqfimtrgnbekpdcsjalo"), 10, 9);
+ test(S("eqsgalomhb"), SV(""), 11, S::npos);
+ test(S("akiteljmoh"), SV("lofbc"), 11, 8);
+ test(S("hlbdfreqjo"), SV("astoegbfpn"), 11, 9);
+ test(S("taqobhlerg"), SV("pdgreqomsncafklhtibj"), 11, 9);
+ test(S("snafbdlghrjkpqtoceim"), SV(""), 0, S::npos);
+ test(S("aemtbrgcklhndjisfpoq"), SV("lbtqd"), 0, S::npos);
+ test(S("pnracgfkjdiholtbqsem"), SV("tboimldpjh"), 0, 0);
+ test(S("dicfltehbsgrmojnpkaq"), SV("slcerthdaiqjfnobgkpm"), 0, 0);
+ test(S("jlnkraeodhcspfgbqitm"), SV(""), 1, S::npos);
+ test(S("lhosrngtmfjikbqpcade"), SV("aqibs"), 1, S::npos);
+ test(S("rbtaqjhgkneisldpmfoc"), SV("gtfblmqinc"), 1, 1);
+ test(S("gpifsqlrdkbonjtmheca"), SV("mkqpbtdalgniorhfescj"), 1, 1);
+ test(S("hdpkobnsalmcfijregtq"), SV(""), 10, S::npos);
+ test(S("jtlshdgqaiprkbcoenfm"), SV("pblas"), 10, 10);
+ test(S("fkdrbqltsgmcoiphneaj"), SV("arosdhcfme"), 10, 10);
+ test(S("crsplifgtqedjohnabmk"), SV("blkhjeogicatqfnpdmsr"), 10, 10);
+ test(S("niptglfbosehkamrdqcj"), SV(""), 19, S::npos);
+ test(S("copqdhstbingamjfkler"), SV("djkqc"), 19, 16);
+ test(S("mrtaefilpdsgocnhqbjk"), SV("lgokshjtpb"), 19, 19);
+ test(S("kojatdhlcmigpbfrqnes"), SV("bqjhtkfepimcnsgrlado"), 19, 19);
+ test(S("eaintpchlqsbdgrkjofm"), SV(""), 20, S::npos);
+ test(S("gjnhidfsepkrtaqbmclo"), SV("nocfa"), 20, 19);
+ test(S("spocfaktqdbiejlhngmr"), SV("bgtajmiedc"), 20, 18);
+ test(S("rphmlekgfscndtaobiqj"), SV("lsckfnqgdahejiopbtmr"), 20, 19);
+ test(S("liatsqdoegkmfcnbhrpj"), SV(""), 21, S::npos);
+ test(S("binjagtfldkrspcomqeh"), SV("gfsrt"), 21, 12);
+ test(S("latkmisecnorjbfhqpdg"), SV("pfsocbhjtm"), 21, 17);
+ test(S("lecfratdjkhnsmqpoigb"), SV("tpflmdnoicjgkberhqsa"), 21, 19);
+}
+
+template <class S, class SV>
+void test1()
+{
+ test(S(""), SV(""), S::npos);
+ test(S(""), SV("laenf"), S::npos);
+ test(S(""), SV("pqlnkmbdjo"), S::npos);
+ test(S(""), SV("qkamfogpnljdcshbreti"), S::npos);
+ test(S("nhmko"), SV(""), S::npos);
+ test(S("lahfb"), SV("irkhs"), 2);
+ test(S("gmfhd"), SV("kantesmpgj"), 1);
+ test(S("odaft"), SV("oknlrstdpiqmjbaghcfe"), 4);
+ test(S("eolhfgpjqk"), SV(""), S::npos);
+ test(S("nbatdlmekr"), SV("bnrpe"), 9);
+ test(S("jdmciepkaq"), SV("jtdaefblso"), 8);
+ test(S("hkbgspoflt"), SV("oselktgbcapndfjihrmq"), 9);
+ test(S("gprdcokbnjhlsfmtieqa"), SV(""), S::npos);
+ test(S("qjghlnftcaismkropdeb"), SV("bjaht"), 19);
+ test(S("pnalfrdtkqcmojiesbhg"), SV("hjlcmgpket"), 19);
+ test(S("pniotcfrhqsmgdkjbael"), SV("htaobedqikfplcgjsmrn"), 19);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ typedef std::string_view SV;
+ test0<S, SV>();
+ test1<S, SV>();
+ }
+#if TEST_STD_VER >= 11
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ typedef std::string_view SV;
+ test0<S, SV>();
+ test1<S, SV>();
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.ops/string_find/string_view_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_find/string_view_size.pass.cpp
new file mode 100644
index 000000000000..096f47e2a991
--- /dev/null
+++ b/test/std/strings/basic.string/string.ops/string_find/string_view_size.pass.cpp
@@ -0,0 +1,159 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find(basic_string_view sv, size_type pos = 0) const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S, class SV>
+void
+test(const S& s, SV sv, typename S::size_type pos, typename S::size_type x)
+{
+ assert(s.find(sv, pos) == x);
+ if (x != S::npos)
+ assert(pos <= x && x + sv.size() <= s.size());
+}
+
+template <class S, class SV>
+void
+test(const S& s, SV sv, typename S::size_type x)
+{
+ assert(s.find(sv) == x);
+ if (x != S::npos)
+ assert(0 <= x && x + sv.size() <= s.size());
+}
+
+template <class S, class SV>
+void test0()
+{
+ test(S(""), SV(""), 0, 0);
+ test(S(""), SV("abcde"), 0, S::npos);
+ test(S(""), SV("abcdeabcde"), 0, S::npos);
+ test(S(""), SV("abcdeabcdeabcdeabcde"), 0, S::npos);
+ test(S(""), SV(""), 1, S::npos);
+ test(S(""), SV("abcde"), 1, S::npos);
+ test(S(""), SV("abcdeabcde"), 1, S::npos);
+ test(S(""), SV("abcdeabcdeabcdeabcde"), 1, S::npos);
+ test(S("abcde"), SV(""), 0, 0);
+ test(S("abcde"), SV("abcde"), 0, 0);
+ test(S("abcde"), SV("abcdeabcde"), 0, S::npos);
+ test(S("abcde"), SV("abcdeabcdeabcdeabcde"), 0, S::npos);
+ test(S("abcde"), SV(""), 1, 1);
+ test(S("abcde"), SV("abcde"), 1, S::npos);
+ test(S("abcde"), SV("abcdeabcde"), 1, S::npos);
+ test(S("abcde"), SV("abcdeabcdeabcdeabcde"), 1, S::npos);
+ test(S("abcde"), SV(""), 2, 2);
+ test(S("abcde"), SV("abcde"), 2, S::npos);
+ test(S("abcde"), SV("abcdeabcde"), 2, S::npos);
+ test(S("abcde"), SV("abcdeabcdeabcdeabcde"), 2, S::npos);
+ test(S("abcde"), SV(""), 4, 4);
+ test(S("abcde"), SV("abcde"), 4, S::npos);
+ test(S("abcde"), SV("abcdeabcde"), 4, S::npos);
+ test(S("abcde"), SV("abcdeabcdeabcdeabcde"), 4, S::npos);
+ test(S("abcde"), SV(""), 5, 5);
+ test(S("abcde"), SV("abcde"), 5, S::npos);
+ test(S("abcde"), SV("abcdeabcde"), 5, S::npos);
+ test(S("abcde"), SV("abcdeabcdeabcdeabcde"), 5, S::npos);
+ test(S("abcde"), SV(""), 6, S::npos);
+ test(S("abcde"), SV("abcde"), 6, S::npos);
+ test(S("abcde"), SV("abcdeabcde"), 6, S::npos);
+ test(S("abcde"), SV("abcdeabcdeabcdeabcde"), 6, S::npos);
+ test(S("abcdeabcde"), SV(""), 0, 0);
+ test(S("abcdeabcde"), SV("abcde"), 0, 0);
+ test(S("abcdeabcde"), SV("abcdeabcde"), 0, 0);
+ test(S("abcdeabcde"), SV("abcdeabcdeabcdeabcde"), 0, S::npos);
+ test(S("abcdeabcde"), SV(""), 1, 1);
+ test(S("abcdeabcde"), SV("abcde"), 1, 5);
+ test(S("abcdeabcde"), SV("abcdeabcde"), 1, S::npos);
+ test(S("abcdeabcde"), SV("abcdeabcdeabcdeabcde"), 1, S::npos);
+ test(S("abcdeabcde"), SV(""), 5, 5);
+ test(S("abcdeabcde"), SV("abcde"), 5, 5);
+ test(S("abcdeabcde"), SV("abcdeabcde"), 5, S::npos);
+ test(S("abcdeabcde"), SV("abcdeabcdeabcdeabcde"), 5, S::npos);
+ test(S("abcdeabcde"), SV(""), 9, 9);
+ test(S("abcdeabcde"), SV("abcde"), 9, S::npos);
+ test(S("abcdeabcde"), SV("abcdeabcde"), 9, S::npos);
+ test(S("abcdeabcde"), SV("abcdeabcdeabcdeabcde"), 9, S::npos);
+ test(S("abcdeabcde"), SV(""), 10, 10);
+ test(S("abcdeabcde"), SV("abcde"), 10, S::npos);
+ test(S("abcdeabcde"), SV("abcdeabcde"), 10, S::npos);
+ test(S("abcdeabcde"), SV("abcdeabcdeabcdeabcde"), 10, S::npos);
+ test(S("abcdeabcde"), SV(""), 11, S::npos);
+ test(S("abcdeabcde"), SV("abcde"), 11, S::npos);
+ test(S("abcdeabcde"), SV("abcdeabcde"), 11, S::npos);
+ test(S("abcdeabcde"), SV("abcdeabcdeabcdeabcde"), 11, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), SV(""), 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcde"), 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcde"), 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcdeabcdeabcde"), 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), SV(""), 1, 1);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcde"), 1, 5);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcde"), 1, 5);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcdeabcdeabcde"), 1, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), SV(""), 10, 10);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcde"), 10, 10);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcde"), 10, 10);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcdeabcdeabcde"), 10, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), SV(""), 19, 19);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcde"), 19, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcde"), 19, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcdeabcdeabcde"), 19, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), SV(""), 20, 20);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcde"), 20, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcde"), 20, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcdeabcdeabcde"), 20, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), SV(""), 21, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcde"), 21, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcde"), 21, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcdeabcdeabcde"), 21, S::npos);
+}
+
+template <class S, class SV>
+void test1()
+{
+ test(S(""), SV(""), 0);
+ test(S(""), SV("abcde"), S::npos);
+ test(S(""), SV("abcdeabcde"), S::npos);
+ test(S(""), SV("abcdeabcdeabcdeabcde"), S::npos);
+ test(S("abcde"), SV(""), 0);
+ test(S("abcde"), SV("abcde"), 0);
+ test(S("abcde"), SV("abcdeabcde"), S::npos);
+ test(S("abcde"), SV("abcdeabcdeabcdeabcde"), S::npos);
+ test(S("abcdeabcde"), SV(""), 0);
+ test(S("abcdeabcde"), SV("abcde"), 0);
+ test(S("abcdeabcde"), SV("abcdeabcde"), 0);
+ test(S("abcdeabcde"), SV("abcdeabcdeabcdeabcde"), S::npos);
+ test(S("abcdeabcdeabcdeabcde"), SV(""), 0);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcde"), 0);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcde"), 0);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcdeabcdeabcde"), 0);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ typedef std::string_view SV;
+ test0<S, SV>();
+ test1<S, SV>();
+ }
+#if TEST_STD_VER >= 11
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ typedef std::string_view SV;
+ test0<S, SV>();
+ test1<S, SV>();
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.ops/string_rfind/string_view_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_rfind/string_view_size.pass.cpp
new file mode 100644
index 000000000000..230c4556cee6
--- /dev/null
+++ b/test/std/strings/basic.string/string.ops/string_rfind/string_view_size.pass.cpp
@@ -0,0 +1,159 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type rfind(basic_string_view sv, size_type pos = npos) const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S, class SV>
+void
+test(const S& s, SV sv, typename S::size_type pos, typename S::size_type x)
+{
+ assert(s.rfind(sv, pos) == x);
+ if (x != S::npos)
+ assert(x <= pos && x + sv.size() <= s.size());
+}
+
+template <class S, class SV>
+void
+test(const S& s, SV sv, typename S::size_type x)
+{
+ assert(s.rfind(sv) == x);
+ if (x != S::npos)
+ assert(0 <= x && x + sv.size() <= s.size());
+}
+
+template <class S, class SV>
+void test0()
+{
+ test(S(""), SV(""), 0, 0);
+ test(S(""), SV("abcde"), 0, S::npos);
+ test(S(""), SV("abcdeabcde"), 0, S::npos);
+ test(S(""), SV("abcdeabcdeabcdeabcde"), 0, S::npos);
+ test(S(""), SV(""), 1, 0);
+ test(S(""), SV("abcde"), 1, S::npos);
+ test(S(""), SV("abcdeabcde"), 1, S::npos);
+ test(S(""), SV("abcdeabcdeabcdeabcde"), 1, S::npos);
+ test(S("abcde"), SV(""), 0, 0);
+ test(S("abcde"), SV("abcde"), 0, 0);
+ test(S("abcde"), SV("abcdeabcde"), 0, S::npos);
+ test(S("abcde"), SV("abcdeabcdeabcdeabcde"), 0, S::npos);
+ test(S("abcde"), SV(""), 1, 1);
+ test(S("abcde"), SV("abcde"), 1, 0);
+ test(S("abcde"), SV("abcdeabcde"), 1, S::npos);
+ test(S("abcde"), SV("abcdeabcdeabcdeabcde"), 1, S::npos);
+ test(S("abcde"), SV(""), 2, 2);
+ test(S("abcde"), SV("abcde"), 2, 0);
+ test(S("abcde"), SV("abcdeabcde"), 2, S::npos);
+ test(S("abcde"), SV("abcdeabcdeabcdeabcde"), 2, S::npos);
+ test(S("abcde"), SV(""), 4, 4);
+ test(S("abcde"), SV("abcde"), 4, 0);
+ test(S("abcde"), SV("abcdeabcde"), 4, S::npos);
+ test(S("abcde"), SV("abcdeabcdeabcdeabcde"), 4, S::npos);
+ test(S("abcde"), SV(""), 5, 5);
+ test(S("abcde"), SV("abcde"), 5, 0);
+ test(S("abcde"), SV("abcdeabcde"), 5, S::npos);
+ test(S("abcde"), SV("abcdeabcdeabcdeabcde"), 5, S::npos);
+ test(S("abcde"), SV(""), 6, 5);
+ test(S("abcde"), SV("abcde"), 6, 0);
+ test(S("abcde"), SV("abcdeabcde"), 6, S::npos);
+ test(S("abcde"), SV("abcdeabcdeabcdeabcde"), 6, S::npos);
+ test(S("abcdeabcde"), SV(""), 0, 0);
+ test(S("abcdeabcde"), SV("abcde"), 0, 0);
+ test(S("abcdeabcde"), SV("abcdeabcde"), 0, 0);
+ test(S("abcdeabcde"), SV("abcdeabcdeabcdeabcde"), 0, S::npos);
+ test(S("abcdeabcde"), SV(""), 1, 1);
+ test(S("abcdeabcde"), SV("abcde"), 1, 0);
+ test(S("abcdeabcde"), SV("abcdeabcde"), 1, 0);
+ test(S("abcdeabcde"), SV("abcdeabcdeabcdeabcde"), 1, S::npos);
+ test(S("abcdeabcde"), SV(""), 5, 5);
+ test(S("abcdeabcde"), SV("abcde"), 5, 5);
+ test(S("abcdeabcde"), SV("abcdeabcde"), 5, 0);
+ test(S("abcdeabcde"), SV("abcdeabcdeabcdeabcde"), 5, S::npos);
+ test(S("abcdeabcde"), SV(""), 9, 9);
+ test(S("abcdeabcde"), SV("abcde"), 9, 5);
+ test(S("abcdeabcde"), SV("abcdeabcde"), 9, 0);
+ test(S("abcdeabcde"), SV("abcdeabcdeabcdeabcde"), 9, S::npos);
+ test(S("abcdeabcde"), SV(""), 10, 10);
+ test(S("abcdeabcde"), SV("abcde"), 10, 5);
+ test(S("abcdeabcde"), SV("abcdeabcde"), 10, 0);
+ test(S("abcdeabcde"), SV("abcdeabcdeabcdeabcde"), 10, S::npos);
+ test(S("abcdeabcde"), SV(""), 11, 10);
+ test(S("abcdeabcde"), SV("abcde"), 11, 5);
+ test(S("abcdeabcde"), SV("abcdeabcde"), 11, 0);
+ test(S("abcdeabcde"), SV("abcdeabcdeabcdeabcde"), 11, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), SV(""), 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcde"), 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcde"), 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcdeabcdeabcde"), 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), SV(""), 1, 1);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcde"), 1, 0);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcde"), 1, 0);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcdeabcdeabcde"), 1, 0);
+ test(S("abcdeabcdeabcdeabcde"), SV(""), 10, 10);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcde"), 10, 10);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcde"), 10, 10);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcdeabcdeabcde"), 10, 0);
+ test(S("abcdeabcdeabcdeabcde"), SV(""), 19, 19);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcde"), 19, 15);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcde"), 19, 10);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcdeabcdeabcde"), 19, 0);
+ test(S("abcdeabcdeabcdeabcde"), SV(""), 20, 20);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcde"), 20, 15);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcde"), 20, 10);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcdeabcdeabcde"), 20, 0);
+ test(S("abcdeabcdeabcdeabcde"), SV(""), 21, 20);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcde"), 21, 15);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcde"), 21, 10);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcdeabcdeabcde"), 21, 0);
+}
+
+template <class S, class SV>
+void test1()
+{
+ test(S(""), SV(""), 0);
+ test(S(""), SV("abcde"), S::npos);
+ test(S(""), SV("abcdeabcde"), S::npos);
+ test(S(""), SV("abcdeabcdeabcdeabcde"), S::npos);
+ test(S("abcde"), SV(""), 5);
+ test(S("abcde"), SV("abcde"), 0);
+ test(S("abcde"), SV("abcdeabcde"), S::npos);
+ test(S("abcde"), SV("abcdeabcdeabcdeabcde"), S::npos);
+ test(S("abcdeabcde"), SV(""), 10);
+ test(S("abcdeabcde"), SV("abcde"), 5);
+ test(S("abcdeabcde"), SV("abcdeabcde"), 0);
+ test(S("abcdeabcde"), SV("abcdeabcdeabcdeabcde"), S::npos);
+ test(S("abcdeabcdeabcdeabcde"), SV(""), 20);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcde"), 15);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcde"), 10);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcdeabcdeabcde"), 0);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ typedef std::string_view SV;
+ test0<S, SV>();
+ test1<S, SV>();
+ }
+#if TEST_STD_VER >= 11
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ typedef std::string_view SV;
+ test0<S, SV>();
+ test1<S, SV>();
+ }
+#endif
+}
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_incomplete.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_incomplete.pass.cpp
index c8f4178a26bd..75e2ecac3c41 100644
--- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_incomplete.pass.cpp
+++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_incomplete.pass.cpp
@@ -16,6 +16,7 @@
// Allow incomplete argument types in the __is_callable check
#include <functional>
+#include <cassert>
struct X{
typedef std::function<void(X&)> callback_type;
@@ -24,6 +25,40 @@ private:
callback_type _cb;
};
-int main()
+struct IncompleteReturnType {
+ std::function<IncompleteReturnType ()> fn;
+};
+
+
+int called = 0;
+IncompleteReturnType test_fn() {
+ ++called;
+ IncompleteReturnType I;
+ return I;
+}
+
+// See llvm.org/PR34298
+void test_pr34298()
{
+ static_assert(std::is_copy_constructible<IncompleteReturnType>::value, "");
+ static_assert(std::is_copy_assignable<IncompleteReturnType>::value, "");
+ {
+ IncompleteReturnType X;
+ X.fn = test_fn;
+ const IncompleteReturnType& CX = X;
+ IncompleteReturnType X2 = CX;
+ assert(X2.fn);
+ assert(called == 0);
+ X2.fn();
+ assert(called == 1);
+ }
+ {
+ IncompleteReturnType Empty;
+ IncompleteReturnType X2 = Empty;
+ assert(!X2.fn);
+ }
+}
+
+int main() {
+ test_pr34298();
}
diff --git a/test/support/container_test_types.h b/test/support/container_test_types.h
index 08e88f091461..b8422ec4602d 100644
--- a/test/support/container_test_types.h
+++ b/test/support/container_test_types.h
@@ -234,6 +234,19 @@ inline ConstructController* getConstructController() {
return &c;
}
+template <class ...Args>
+struct ExpectConstructGuard {
+ ExpectConstructGuard(int N) {
+ auto CC = getConstructController();
+ assert(!CC->unchecked());
+ CC->expect<Args...>(N);
+ }
+
+ ~ExpectConstructGuard() {
+ assert(!getConstructController()->unchecked());
+ }
+};
+
//===----------------------------------------------------------------------===//
// ContainerTestAllocator
//===----------------------------------------------------------------------===//
@@ -417,7 +430,12 @@ namespace std {
return arg.data;
}
};
-
+ template <class T, class Alloc>
+ class vector;
+ template <class T, class Alloc>
+ class deque;
+ template <class T, class Alloc>
+ class list;
template <class _Key, class _Value, class _Less, class _Alloc>
class map;
template <class _Key, class _Value, class _Less, class _Alloc>
@@ -444,6 +462,13 @@ _LIBCPP_END_NAMESPACE_STD
// TCT - Test container type
namespace TCT {
+template <class T = CopyInsertable<1>>
+using vector = std::vector<T, ContainerTestAllocator<T, T> >;
+template <class T = CopyInsertable<1>>
+using deque = std::deque<T, ContainerTestAllocator<T, T> >;
+template <class T = CopyInsertable<1>>
+using list = std::list<T, ContainerTestAllocator<T, T> >;
+
template <class Key = CopyInsertable<1>, class Value = CopyInsertable<2>,
class ValueTp = std::pair<const Key, Value> >
using unordered_map =
@@ -488,5 +513,4 @@ using multiset =
} // end namespace TCT
-
#endif // SUPPORT_CONTAINER_TEST_TYPES_H
diff --git a/test/support/emplace_constructible.h b/test/support/emplace_constructible.h
new file mode 100644
index 000000000000..f2bc0ec6a367
--- /dev/null
+++ b/test/support/emplace_constructible.h
@@ -0,0 +1,74 @@
+#ifndef TEST_SUPPORT_EMPLACE_CONSTRUCTIBLE_H
+#define TEST_SUPPORT_EMPLACE_CONSTRUCTIBLE_H
+
+#include "test_macros.h"
+
+#if TEST_STD_VER >= 11
+template <class T>
+struct EmplaceConstructible {
+ T value;
+ explicit EmplaceConstructible(T value) : value(value) {}
+ EmplaceConstructible(EmplaceConstructible const&) = delete;
+};
+
+template <class T>
+struct EmplaceConstructibleAndMoveInsertable {
+ int copied = 0;
+ T value;
+ explicit EmplaceConstructibleAndMoveInsertable(T value) : value(value) {}
+
+ EmplaceConstructibleAndMoveInsertable(
+ EmplaceConstructibleAndMoveInsertable&& Other)
+ : copied(Other.copied + 1), value(std::move(Other.value)) {}
+};
+
+template <class T>
+struct EmplaceConstructibleAndMoveable {
+ int copied = 0;
+ int assigned = 0;
+ T value;
+ explicit EmplaceConstructibleAndMoveable(T value) noexcept : value(value) {}
+
+ EmplaceConstructibleAndMoveable(EmplaceConstructibleAndMoveable&& Other)
+ noexcept : copied(Other.copied + 1),
+ value(std::move(Other.value)) {}
+
+ EmplaceConstructibleAndMoveable&
+ operator=(EmplaceConstructibleAndMoveable&& Other) noexcept {
+ copied = Other.copied;
+ assigned = Other.assigned + 1;
+ value = std::move(Other.value);
+ return *this;
+ }
+};
+
+template <class T>
+struct EmplaceConstructibleMoveableAndAssignable {
+ int copied = 0;
+ int assigned = 0;
+ T value;
+ explicit EmplaceConstructibleMoveableAndAssignable(T value) noexcept
+ : value(value) {}
+
+ EmplaceConstructibleMoveableAndAssignable(
+ EmplaceConstructibleMoveableAndAssignable&& Other) noexcept
+ : copied(Other.copied + 1),
+ value(std::move(Other.value)) {}
+
+ EmplaceConstructibleMoveableAndAssignable&
+ operator=(EmplaceConstructibleMoveableAndAssignable&& Other) noexcept {
+ copied = Other.copied;
+ assigned = Other.assigned + 1;
+ value = std::move(Other.value);
+ return *this;
+ }
+
+ EmplaceConstructibleMoveableAndAssignable& operator=(T xvalue) {
+ value = std::move(xvalue);
+ ++assigned;
+ return *this;
+ }
+};
+#endif
+
+#endif // TEST_SUPPORT_EMPLACE_CONSTRUCTIBLE_H