svn commit: r326465 - in vendor/libc++/dist: include test/std/containers/sequences/deque/deque.cons test/std/containers/sequences/list/list.cons test/std/containers/sequences/vector/vector.cons tes...
Dimitry Andric
dim at FreeBSD.org
Sat Dec 2 12:47:14 UTC 2017
Author: dim
Date: Sat Dec 2 12:47:11 2017
New Revision: 326465
URL: https://svnweb.freebsd.org/changeset/base/326465
Log:
Vendor import of libc++ release_50 branch r319231:
https://llvm.org/svn/llvm-project/libcxx/branches/release_50@319231
Added:
vendor/libc++/dist/test/std/containers/sequences/vector/vector.cons/assign_iter_iter.pass.cpp (contents, props changed)
vendor/libc++/dist/test/std/strings/basic.string/string.ops/string_compare/size_size_string_view.pass.cpp (contents, props changed)
vendor/libc++/dist/test/std/strings/basic.string/string.ops/string_compare/string_view.pass.cpp (contents, props changed)
vendor/libc++/dist/test/std/strings/basic.string/string.ops/string_find.first.not.of/string_view_size.pass.cpp (contents, props changed)
vendor/libc++/dist/test/std/strings/basic.string/string.ops/string_find.first.of/string_view_size.pass.cpp (contents, props changed)
vendor/libc++/dist/test/std/strings/basic.string/string.ops/string_find.last.not.of/string_view_size.pass.cpp (contents, props changed)
vendor/libc++/dist/test/std/strings/basic.string/string.ops/string_find.last.of/string_view_size.pass.cpp (contents, props changed)
vendor/libc++/dist/test/std/strings/basic.string/string.ops/string_find/string_view_size.pass.cpp (contents, props changed)
vendor/libc++/dist/test/std/strings/basic.string/string.ops/string_rfind/string_view_size.pass.cpp (contents, props changed)
vendor/libc++/dist/test/support/emplace_constructible.h (contents, props changed)
Modified:
vendor/libc++/dist/include/algorithm
vendor/libc++/dist/include/deque
vendor/libc++/dist/include/functional
vendor/libc++/dist/include/list
vendor/libc++/dist/include/string
vendor/libc++/dist/include/type_traits
vendor/libc++/dist/include/vector
vendor/libc++/dist/test/std/containers/sequences/deque/deque.cons/assign_iter_iter.pass.cpp
vendor/libc++/dist/test/std/containers/sequences/deque/deque.cons/iter_iter.pass.cpp
vendor/libc++/dist/test/std/containers/sequences/deque/deque.cons/iter_iter_alloc.pass.cpp
vendor/libc++/dist/test/std/containers/sequences/list/list.cons/input_iterator.pass.cpp
vendor/libc++/dist/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp
vendor/libc++/dist/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp
vendor/libc++/dist/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_incomplete.pass.cpp
vendor/libc++/dist/test/support/container_test_types.h
Modified: vendor/libc++/dist/include/algorithm
==============================================================================
--- vendor/libc++/dist/include/algorithm Sat Dec 2 12:47:02 2017 (r326464)
+++ vendor/libc++/dist/include/algorithm Sat Dec 2 12:47:11 2017 (r326465)
@@ -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(
{
__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(
{
__u = __e_() - _Engine::min();
} while (__u >= __y1_);
- if (__w0_ < _WDt - 1)
+ if (__w0_ < _WRt - 1)
_Sp <<= __w0_ + 1;
else
_Sp = 0;
Modified: vendor/libc++/dist/include/deque
==============================================================================
--- vendor/libc++/dist/include/deque Sat Dec 2 12:47:02 2017 (r326464)
+++ vendor/libc++/dist/include/deque Sat Dec 2 12:47:11 2017 (r326465)
@@ -1356,7 +1356,6 @@ class _LIBCPP_TEMPLATE_VIS deque (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, _InpIte
!__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>
Modified: vendor/libc++/dist/include/functional
==============================================================================
--- vendor/libc++/dist/include/functional Sat Dec 2 12:47:02 2017 (r326464)
+++ vendor/libc++/dist/include/functional Sat Dec 2 12:47:11 2017 (r326465)
@@ -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 @@ class _LIBCPP_TEMPLATE_VIS function<_Rp(_ArgTypes...)>
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 @@ class _LIBCPP_TEMPLATE_VIS function<_Rp(_ArgTypes...)>
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) _NOE
}
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);
Modified: vendor/libc++/dist/include/list
==============================================================================
--- vendor/libc++/dist/include/list Sat Dec 2 12:47:02 2017 (r326464)
+++ vendor/libc++/dist/include/list Sat Dec 2 12:47:11 2017 (r326465)
@@ -992,6 +992,15 @@ class _LIBCPP_TEMPLATE_VIS list (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, co
__get_db()->__insert_c(this);
#endif
for (; __f != __l; ++__f)
- push_back(*__f);
+ __emplace_back(*__f);
}
template <class _Tp, class _Alloc>
Modified: vendor/libc++/dist/include/string
==============================================================================
--- vendor/libc++/dist/include/string Sat Dec 2 12:47:02 2017 (r326464)
+++ vendor/libc++/dist/include/string Sat Dec 2 12:47:11 2017 (r326465)
@@ -259,7 +259,7 @@ class basic_string (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 @@ class basic_string (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 @@ class basic_string (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 @@ class _LIBCPP_TEMPLATE_VIS basic_string (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 @@ class _LIBCPP_TEMPLATE_VIS basic_string (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 @@ class _LIBCPP_TEMPLATE_VIS basic_string (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;
Modified: vendor/libc++/dist/include/type_traits
==============================================================================
--- vendor/libc++/dist/include/type_traits Sat Dec 2 12:47:02 2017 (r326464)
+++ vendor/libc++/dist/include/type_traits Sat Dec 2 12:47:11 2017 (r326465)
@@ -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>
Modified: vendor/libc++/dist/include/vector
==============================================================================
--- vendor/libc++/dist/include/vector Sat Dec 2 12:47:02 2017 (r326464)
+++ vendor/libc++/dist/include/vector Sat Dec 2 12:47:11 2017 (r326465)
@@ -674,6 +674,17 @@ class _LIBCPP_TEMPLATE_VIS vector (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
__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
{
clear();
for (; __first != __last; ++__first)
- push_back(*__first);
+ __emplace_back(*__first);
}
template <class _Tp, class _Allocator>
Modified: vendor/libc++/dist/test/std/containers/sequences/deque/deque.cons/assign_iter_iter.pass.cpp
==============================================================================
--- vendor/libc++/dist/test/std/containers/sequences/deque/deque.cons/assign_iter_iter.pass.cpp Sat Dec 2 12:47:02 2017 (r326464)
+++ vendor/libc++/dist/test/std/containers/sequences/deque/deque.cons/assign_iter_iter.pass.cpp Sat Dec 2 12:47:11 2017 (r326465)
@@ -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};
@@ -102,4 +105,52 @@ int main()
testNI<std::deque<int, min_allocator<int>> >(1500, 2000, 1000);
}
#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();
}
Modified: vendor/libc++/dist/test/std/containers/sequences/deque/deque.cons/iter_iter.pass.cpp
==============================================================================
--- vendor/libc++/dist/test/std/containers/sequences/deque/deque.cons/iter_iter.pass.cpp Sat Dec 2 12:47:02 2017 (r326464)
+++ vendor/libc++/dist/test/std/containers/sequences/deque/deque.cons/iter_iter.pass.cpp Sat Dec 2 12:47:11 2017 (r326465)
@@ -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]);
@@ -60,4 +64,49 @@ int main()
#if TEST_STD_VER >= 11
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();
}
Modified: vendor/libc++/dist/test/std/containers/sequences/deque/deque.cons/iter_iter_alloc.pass.cpp
==============================================================================
--- vendor/libc++/dist/test/std/containers/sequences/deque/deque.cons/iter_iter_alloc.pass.cpp Sat Dec 2 12:47:02 2017 (r326464)
+++ vendor/libc++/dist/test/std/containers/sequences/deque/deque.cons/iter_iter_alloc.pass.cpp Sat Dec 2 12:47:11 2017 (r326465)
@@ -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
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]);
@@ -49,4 +53,51 @@ int main()
test(bidirectional_iterator<const int*>(ab), bidirectional_iterator<const int*>(an), min_allocator<int>());
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();
}
Modified: vendor/libc++/dist/test/std/containers/sequences/list/list.cons/input_iterator.pass.cpp
==============================================================================
--- vendor/libc++/dist/test/std/containers/sequences/list/list.cons/input_iterator.pass.cpp Sat Dec 2 12:47:02 2017 (r326464)
+++ vendor/libc++/dist/test/std/containers/sequences/list/list.cons/input_iterator.pass.cpp Sat Dec 2 12:47:11 2017 (r326465)
@@ -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};
@@ -75,4 +79,180 @@ int main()
assert(*i == j);
}
#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();
}
Added: vendor/libc++/dist/test/std/containers/sequences/vector/vector.cons/assign_iter_iter.pass.cpp
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ vendor/libc++/dist/test/std/containers/sequences/vector/vector.cons/assign_iter_iter.pass.cpp Sat Dec 2 12:47:11 2017 (r326465)
@@ -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();
+}
Modified: vendor/libc++/dist/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp
==============================================================================
--- vendor/libc++/dist/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp Sat Dec 2 12:47:02 2017 (r326464)
+++ vendor/libc++/dist/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp Sat Dec 2 12:47:11 2017 (r326465)
@@ -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);
}
-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);
+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);
+ 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);
+ 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
+}
+
+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*>;
+ {
+ 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();
}
Modified: vendor/libc++/dist/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp
==============================================================================
--- vendor/libc++/dist/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp Sat Dec 2 12:47:02 2017 (r326464)
+++ vendor/libc++/dist/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp Sat Dec 2 12:47:11 2017 (r326465)
@@ -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;
*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
More information about the svn-src-all
mailing list