<div dir="ltr">These shadowing warnings should be fixed now.<div><br></div><div>/Eric</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Oct 17, 2017 at 10:03 AM, Maxim Kuvyrkov <span dir="ltr"><<a href="mailto:maxim.kuvyrkov@linaro.org" target="_blank">maxim.kuvyrkov@linaro.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Eric,<br>
<br>
This seems to have broken ARM and AArch64 buildbots:<br>
<br>
<a href="http://lab.llvm.org:8011/builders/libcxx-libcxxabi-libunwind-arm-linux/builds/850" rel="noreferrer" target="_blank">http://lab.llvm.org:8011/<wbr>builders/libcxx-libcxxabi-<wbr>libunwind-arm-linux/builds/850</a><br>
<a href="http://lab.llvm.org:8011/builders/libcxx-libcxxabi-libunwind-arm-linux-noexceptions/builds/931" rel="noreferrer" target="_blank">http://lab.llvm.org:8011/<wbr>builders/libcxx-libcxxabi-<wbr>libunwind-arm-linux-<wbr>noexceptions/builds/931</a><br>
<a href="http://lab.llvm.org:8011/builders/libcxx-libcxxabi-libunwind-aarch64-linux/builds/873" rel="noreferrer" target="_blank">http://lab.llvm.org:8011/<wbr>builders/libcxx-libcxxabi-<wbr>libunwind-aarch64-linux/<wbr>builds/873</a><br>
<a href="http://lab.llvm.org:8011/builders/libcxx-libcxxabi-libunwind-aarch64-linux-noexceptions/builds/826" rel="noreferrer" target="_blank">http://lab.llvm.org:8011/<wbr>builders/libcxx-libcxxabi-<wbr>libunwind-aarch64-linux-<wbr>noexceptions/builds/826</a><br>
<br>
Would you please take a look?<br>
<br>
--<br>
Maxim Kuvyrkov<br>
<a href="http://www.linaro.org" rel="noreferrer" target="_blank">www.linaro.org</a><br>
<div class="HOEnZb"><div class="h5"><br>
<br>
<br>
> On Oct 17, 2017, at 4:03 PM, Eric Fiselier via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>> wrote:<br>
><br>
> Author: ericwf<br>
> Date: Tue Oct 17 06:03:17 2017<br>
> New Revision: 315994<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=315994&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=315994&view=rev</a><br>
> Log:<br>
> [libc++] Fix PR34898 - vector iterator constructors and assign method perform push_back instead of emplace_back.<br>
><br>
> Summary:<br>
> The constructors `vector(Iter, Iter, Alloc = Alloc{})` and `assign(Iter, Iter)` don't correctly perform EmplaceConstruction from the result of dereferencing the iterator. This results in them performing an additional and unneeded copy.<br>
><br>
> This patch addresses the issue by correctly using `emplace_back` in C++11 and newer.<br>
><br>
> There are also some bugs in our `insert` implementation, but those will be handled separately.<br>
><br>
> @mclow.lists We should probably merge this into 5.1, agreed?<br>
><br>
> Reviewers: mclow.lists, dlj, EricWF<br>
><br>
> Reviewed By: mclow.lists, EricWF<br>
><br>
> Subscribers: cfe-commits, mclow.lists<br>
><br>
> Differential Revision: <a href="https://reviews.llvm.org/D38757" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D38757</a><br>
><br>
> Added:<br>
>    libcxx/trunk/test/std/<wbr>containers/sequences/vector/<wbr>vector.cons/assign_iter_iter.<wbr>pass.cpp<br>
>    libcxx/trunk/test/support/<wbr>emplace_constructible.h<br>
> Modified:<br>
>    libcxx/trunk/include/deque<br>
>    libcxx/trunk/include/list<br>
>    libcxx/trunk/include/vector<br>
>    libcxx/trunk/test/std/<wbr>containers/sequences/deque/<wbr>deque.cons/assign_iter_iter.<wbr>pass.cpp<br>
>    libcxx/trunk/test/std/<wbr>containers/sequences/deque/<wbr>deque.cons/iter_iter.pass.cpp<br>
>    libcxx/trunk/test/std/<wbr>containers/sequences/deque/<wbr>deque.cons/iter_iter_alloc.<wbr>pass.cpp<br>
>    libcxx/trunk/test/std/<wbr>containers/sequences/list/<wbr>list.cons/input_iterator.pass.<wbr>cpp<br>
>    libcxx/trunk/test/std/<wbr>containers/sequences/vector/<wbr>vector.cons/construct_iter_<wbr>iter.pass.cpp<br>
>    libcxx/trunk/test/std/<wbr>containers/sequences/vector/<wbr>vector.cons/construct_iter_<wbr>iter_alloc.pass.cpp<br>
>    libcxx/trunk/test/support/<wbr>container_test_types.h<br>
><br>
> Modified: libcxx/trunk/include/deque<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/deque?rev=315994&r1=315993&r2=315994&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/libcxx/trunk/include/<wbr>deque?rev=315994&r1=315993&r2=<wbr>315994&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- libcxx/trunk/include/deque (original)<br>
> +++ libcxx/trunk/include/deque Tue Oct 17 06:03:17 2017<br>
> @@ -1356,7 +1356,6 @@ public:<br>
>     iterator insert(const_iterator __p, initializer_list<value_type> __il)<br>
>         {return insert(__p, __il.begin(), __il.end());}<br>
> #endif  // _LIBCPP_CXX03_LANG<br>
> -<br>
>     iterator insert(const_iterator __p, const value_type& __v);<br>
>     iterator insert(const_iterator __p, size_type __n, const value_type& __v);<br>
>     template <class _InputIter><br>
> @@ -2224,7 +2223,11 @@ deque<_Tp, _Allocator>::__append(_InpIte<br>
>                                                    !__is_forward_iterator<_<wbr>InpIter>::value>::type*)<br>
> {<br>
>     for (; __f != __l; ++__f)<br>
> +#ifdef _LIBCPP_CXX03_LANG<br>
>         push_back(*__f);<br>
> +#else<br>
> +        emplace_back(*__f);<br>
> +#endif<br>
> }<br>
><br>
> template <class _Tp, class _Allocator><br>
><br>
> Modified: libcxx/trunk/include/list<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/list?rev=315994&r1=315993&r2=315994&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/libcxx/trunk/include/<wbr>list?rev=315994&r1=315993&r2=<wbr>315994&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- libcxx/trunk/include/list (original)<br>
> +++ libcxx/trunk/include/list Tue Oct 17 06:03:17 2017<br>
> @@ -992,6 +992,15 @@ public:<br>
>     void push_front(const value_type& __x);<br>
>     void push_back(const value_type& __x);<br>
><br>
> +#ifndef _LIBCPP_CXX03_LANG<br>
> +    template <class _Arg><br>
> +    _LIBCPP_INLINE_VISIBILITY<br>
> +    void __emplace_back(_Arg&& __arg) { emplace_back(_VSTD::forward<_<wbr>Arg>(__arg)); }<br>
> +#else<br>
> +    _LIBCPP_INLINE_VISIBILITY<br>
> +    void __emplace_back(value_type const& __arg) { push_back(__arg); }<br>
> +#endif<br>
> +<br>
>     iterator insert(const_iterator __p, const value_type& __x);<br>
>     iterator insert(const_iterator __p, size_type __n, const value_type& __x);<br>
>     template <class _InpIter><br>
> @@ -1189,7 +1198,7 @@ list<_Tp, _Alloc>::list(_InpIter __f, _I<br>
>     __get_db()->__insert_c(this);<br>
> #endif<br>
>     for (; __f != __l; ++__f)<br>
> -        push_back(*__f);<br>
> +        __emplace_back(*__f);<br>
> }<br>
><br>
> template <class _Tp, class _Alloc><br>
> @@ -1202,7 +1211,7 @@ list<_Tp, _Alloc>::list(_InpIter __f, _I<br>
>     __get_db()->__insert_c(this);<br>
> #endif<br>
>     for (; __f != __l; ++__f)<br>
> -        push_back(*__f);<br>
> +        __emplace_back(*__f);<br>
> }<br>
><br>
> template <class _Tp, class _Alloc><br>
><br>
> Modified: libcxx/trunk/include/vector<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/vector?rev=315994&r1=315993&r2=315994&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/libcxx/trunk/include/<wbr>vector?rev=315994&r1=315993&<wbr>r2=315994&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- libcxx/trunk/include/vector (original)<br>
> +++ libcxx/trunk/include/vector Tue Oct 17 06:03:17 2017<br>
> @@ -674,6 +674,17 @@ public:<br>
>     const value_type* data() const _NOEXCEPT<br>
>         {return _VSTD::__to_raw_pointer(this-><wbr>__begin_);}<br>
><br>
> +#ifdef _LIBCPP_CXX03_LANG<br>
> +    _LIBCPP_INLINE_VISIBILITY<br>
> +    void __emplace_back(const value_type& __x) { push_back(__x); }<br>
> +#else<br>
> +    template <class _Arg><br>
> +    _LIBCPP_INLINE_VISIBILITY<br>
> +    void __emplace_back(_Arg&& __arg) {<br>
> +      emplace_back(_VSTD::forward<_<wbr>Arg>(__arg));<br>
> +    }<br>
> +#endif<br>
> +<br>
>     _LIBCPP_INLINE_VISIBILITY void push_back(const_reference __x);<br>
><br>
> #ifndef _LIBCPP_CXX03_LANG<br>
> @@ -1128,7 +1139,7 @@ vector<_Tp, _Allocator>::vector(_InputIt<br>
>     __get_db()->__insert_c(this);<br>
> #endif<br>
>     for (; __first != __last; ++__first)<br>
> -        push_back(*__first);<br>
> +        __emplace_back(*__first);<br>
> }<br>
><br>
> template <class _Tp, class _Allocator><br>
> @@ -1145,7 +1156,7 @@ vector<_Tp, _Allocator>::vector(_InputIt<br>
>     __get_db()->__insert_c(this);<br>
> #endif<br>
>     for (; __first != __last; ++__first)<br>
> -        push_back(*__first);<br>
> +        __emplace_back(*__first);<br>
> }<br>
><br>
> template <class _Tp, class _Allocator><br>
> @@ -1365,7 +1376,7 @@ vector<_Tp, _Allocator>::assign(_InputIt<br>
> {<br>
>     clear();<br>
>     for (; __first != __last; ++__first)<br>
> -        push_back(*__first);<br>
> +        __emplace_back(*__first);<br>
> }<br>
><br>
> template <class _Tp, class _Allocator><br>
><br>
> Modified: libcxx/trunk/test/std/<wbr>containers/sequences/deque/<wbr>deque.cons/assign_iter_iter.<wbr>pass.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/deque/deque.cons/assign_iter_iter.pass.cpp?rev=315994&r1=315993&r2=315994&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/libcxx/trunk/test/std/<wbr>containers/sequences/deque/<wbr>deque.cons/assign_iter_iter.<wbr>pass.cpp?rev=315994&r1=315993&<wbr>r2=315994&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- libcxx/trunk/test/std/<wbr>containers/sequences/deque/<wbr>deque.cons/assign_iter_iter.<wbr>pass.cpp (original)<br>
> +++ libcxx/trunk/test/std/<wbr>containers/sequences/deque/<wbr>deque.cons/assign_iter_iter.<wbr>pass.cpp Tue Oct 17 06:03:17 2017<br>
> @@ -19,6 +19,9 @@<br>
> #include "test_macros.h"<br>
> #include "test_iterators.h"<br>
> #include "min_allocator.h"<br>
> +#if TEST_STD_VER >= 11<br>
> +#include "emplace_constructible.h"<br>
> +#endif<br>
><br>
> template <class C><br>
> C<br>
> @@ -80,7 +83,7 @@ testNI(int start, int N, int M)<br>
>     testI(c1, c2);<br>
> }<br>
><br>
> -int main()<br>
> +void basic_test()<br>
> {<br>
>     {<br>
>     int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};<br>
> @@ -103,3 +106,51 @@ int main()<br>
>     }<br>
> #endif<br>
> }<br>
> +<br>
> +void test_emplacable_concept() {<br>
> +#if TEST_STD_VER >= 11<br>
> +  int arr1[] = {42};<br>
> +  int arr2[] = {1, 101, 42};<br>
> +  {<br>
> +    using T = EmplaceConstructibleMoveableAn<wbr>dAssignable<int>;<br>
> +    using It = random_access_iterator<int*>;<br>
> +    {<br>
> +      std::deque<T> v;<br>
> +      v.assign(It(arr1), It(std::end(arr1)));<br>
> +      assert(v[0].value == 42);<br>
> +    }<br>
> +    {<br>
> +      std::deque<T> v;<br>
> +      v.assign(It(arr2), It(std::end(arr2)));<br>
> +      assert(v[0].value == 1);<br>
> +      assert(v[1].value == 101);<br>
> +      assert(v[2].value == 42);<br>
> +    }<br>
> +  }<br>
> +  {<br>
> +    using T = EmplaceConstructibleMoveableAn<wbr>dAssignable<int>;<br>
> +    using It = input_iterator<int*>;<br>
> +    {<br>
> +      std::deque<T> v;<br>
> +      v.assign(It(arr1), It(std::end(arr1)));<br>
> +      assert(v[0].copied == 0);<br>
> +      assert(v[0].value == 42);<br>
> +    }<br>
> +    {<br>
> +      std::deque<T> v;<br>
> +      v.assign(It(arr2), It(std::end(arr2)));<br>
> +      //assert(v[0].copied == 0);<br>
> +      assert(v[0].value == 1);<br>
> +      //assert(v[1].copied == 0);<br>
> +      assert(v[1].value == 101);<br>
> +      assert(v[2].copied == 0);<br>
> +      assert(v[2].value == 42);<br>
> +    }<br>
> +  }<br>
> +#endif<br>
> +}<br>
> +<br>
> +int main() {<br>
> +  basic_test();<br>
> +  test_emplacable_concept();<br>
> +}<br>
><br>
> Modified: libcxx/trunk/test/std/<wbr>containers/sequences/deque/<wbr>deque.cons/iter_iter.pass.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/deque/deque.cons/iter_iter.pass.cpp?rev=315994&r1=315993&r2=315994&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/libcxx/trunk/test/std/<wbr>containers/sequences/deque/<wbr>deque.cons/iter_iter.pass.cpp?<wbr>rev=315994&r1=315993&r2=<wbr>315994&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- libcxx/trunk/test/std/<wbr>containers/sequences/deque/<wbr>deque.cons/iter_iter.pass.cpp (original)<br>
> +++ libcxx/trunk/test/std/<wbr>containers/sequences/deque/<wbr>deque.cons/iter_iter.pass.cpp Tue Oct 17 06:03:17 2017<br>
> @@ -15,9 +15,13 @@<br>
> #include <cassert><br>
> #include <cstddef><br>
><br>
> +#include "test_macros.h"<br>
> #include "test_allocator.h"<br>
> #include "test_iterators.h"<br>
> #include "min_allocator.h"<br>
> +#if TEST_STD_VER >= 11<br>
> +#include "emplace_constructible.h"<br>
> +#endif<br>
><br>
> template <class InputIterator><br>
> void<br>
> @@ -48,7 +52,7 @@ test(InputIterator f, InputIterator l)<br>
>         assert(*i == *f);<br>
> }<br>
><br>
> -int main()<br>
> +void basic_test()<br>
> {<br>
>     int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};<br>
>     int* an = ab + sizeof(ab)/sizeof(ab[0]);<br>
> @@ -61,3 +65,48 @@ int main()<br>
>     test<min_allocator<int> >(ab, an);<br>
> #endif<br>
> }<br>
> +<br>
> +<br>
> +void test_emplacable_concept() {<br>
> +#if TEST_STD_VER >= 11<br>
> +  int arr1[] = {42};<br>
> +  int arr2[] = {1, 101, 42};<br>
> +  {<br>
> +    using T = EmplaceConstructibleAndMoveabl<wbr>e<int>;<br>
> +    using It = random_access_iterator<int*>;<br>
> +    {<br>
> +      std::deque<T> v(It(arr1), It(std::end(arr1)));<br>
> +      assert(v[0].value == 42);<br>
> +    }<br>
> +    {<br>
> +      std::deque<T> v(It(arr2), It(std::end(arr2)));<br>
> +      assert(v[0].value == 1);<br>
> +      assert(v[1].value == 101);<br>
> +      assert(v[2].value == 42);<br>
> +    }<br>
> +  }<br>
> +  {<br>
> +    using T = EmplaceConstructibleAndMoveabl<wbr>e<int>;<br>
> +    using It = input_iterator<int*>;<br>
> +    {<br>
> +      std::deque<T> v(It(arr1), It(std::end(arr1)));<br>
> +      assert(v[0].copied == 0);<br>
> +      assert(v[0].value == 42);<br>
> +    }<br>
> +    {<br>
> +      std::deque<T> v(It(arr2), It(std::end(arr2)));<br>
> +      //assert(v[0].copied == 0);<br>
> +      assert(v[0].value == 1);<br>
> +      //assert(v[1].copied == 0);<br>
> +      assert(v[1].value == 101);<br>
> +      assert(v[2].copied == 0);<br>
> +      assert(v[2].value == 42);<br>
> +    }<br>
> +  }<br>
> +#endif<br>
> +}<br>
> +<br>
> +int main() {<br>
> +  basic_test();<br>
> +  test_emplacable_concept();<br>
> +}<br>
><br>
> Modified: libcxx/trunk/test/std/<wbr>containers/sequences/deque/<wbr>deque.cons/iter_iter_alloc.<wbr>pass.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/deque/deque.cons/iter_iter_alloc.pass.cpp?rev=315994&r1=315993&r2=315994&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/libcxx/trunk/test/std/<wbr>containers/sequences/deque/<wbr>deque.cons/iter_iter_alloc.<wbr>pass.cpp?rev=315994&r1=315993&<wbr>r2=315994&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- libcxx/trunk/test/std/<wbr>containers/sequences/deque/<wbr>deque.cons/iter_iter_alloc.<wbr>pass.cpp (original)<br>
> +++ libcxx/trunk/test/std/<wbr>containers/sequences/deque/<wbr>deque.cons/iter_iter_alloc.<wbr>pass.cpp Tue Oct 17 06:03:17 2017<br>
> @@ -16,9 +16,13 @@<br>
> #include <cassert><br>
> #include <cstddef><br>
><br>
> +#include "test_macros.h"<br>
> #include "test_iterators.h"<br>
> #include "test_allocator.h"<br>
> #include "min_allocator.h"<br>
> +#if TEST_STD_VER >= 11<br>
> +#include "emplace_constructible.h"<br>
> +#endif<br>
><br>
> template <class InputIterator, class Allocator><br>
> void<br>
> @@ -35,7 +39,7 @@ test(InputIterator f, InputIterator l, c<br>
>         assert(*i == *f);<br>
> }<br>
><br>
> -int main()<br>
> +void basic_test()<br>
> {<br>
>     int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};<br>
>     int* an = ab + sizeof(ab)/sizeof(ab[0]);<br>
> @@ -50,3 +54,50 @@ int main()<br>
>     test(random_access_iterator<<wbr>const int*>(ab), random_access_iterator<const int*>(an), min_allocator<int>());<br>
> #endif<br>
> }<br>
> +<br>
> +<br>
> +void test_emplacable_concept() {<br>
> +#if TEST_STD_VER >= 11<br>
> +  int arr1[] = {42};<br>
> +  int arr2[] = {1, 101, 42};<br>
> +  {<br>
> +    using T = EmplaceConstructibleAndMoveabl<wbr>e<int>;<br>
> +    using It = random_access_iterator<int*>;<br>
> +    std::allocator<T> a;<br>
> +    {<br>
> +      std::deque<T> v(It(arr1), It(std::end(arr1)), a);<br>
> +      assert(v[0].value == 42);<br>
> +    }<br>
> +    {<br>
> +      std::deque<T> v(It(arr2), It(std::end(arr2)), a);<br>
> +      assert(v[0].value == 1);<br>
> +      assert(v[1].value == 101);<br>
> +      assert(v[2].value == 42);<br>
> +    }<br>
> +  }<br>
> +  {<br>
> +    using T = EmplaceConstructibleAndMoveabl<wbr>e<int>;<br>
> +    using It = input_iterator<int*>;<br>
> +    std::allocator<T> a;<br>
> +    {<br>
> +      std::deque<T> v(It(arr1), It(std::end(arr1)), a);<br>
> +      assert(v[0].copied == 0);<br>
> +      assert(v[0].value == 42);<br>
> +    }<br>
> +    {<br>
> +      std::deque<T> v(It(arr2), It(std::end(arr2)), a);<br>
> +      //assert(v[0].copied == 0);<br>
> +      assert(v[0].value == 1);<br>
> +      //assert(v[1].copied == 0);<br>
> +      assert(v[1].value == 101);<br>
> +      assert(v[2].copied == 0);<br>
> +      assert(v[2].value == 42);<br>
> +    }<br>
> +  }<br>
> +#endif<br>
> +}<br>
> +<br>
> +int main() {<br>
> +  basic_test();<br>
> +  test_emplacable_concept();<br>
> +}<br>
><br>
> Modified: libcxx/trunk/test/std/<wbr>containers/sequences/list/<wbr>list.cons/input_iterator.pass.<wbr>cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/list/list.cons/input_iterator.pass.cpp?rev=315994&r1=315993&r2=315994&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/libcxx/trunk/test/std/<wbr>containers/sequences/list/<wbr>list.cons/input_iterator.pass.<wbr>cpp?rev=315994&r1=315993&r2=<wbr>315994&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- libcxx/trunk/test/std/<wbr>containers/sequences/list/<wbr>list.cons/input_iterator.pass.<wbr>cpp (original)<br>
> +++ libcxx/trunk/test/std/<wbr>containers/sequences/list/<wbr>list.cons/input_iterator.pass.<wbr>cpp Tue Oct 17 06:03:17 2017<br>
> @@ -17,8 +17,12 @@<br>
> #include "test_iterators.h"<br>
> #include "test_allocator.h"<br>
> #include "min_allocator.h"<br>
> +#if TEST_STD_VER >= 11<br>
> +#include "emplace_constructible.h"<br>
> +#include "container_test_types.h"<br>
> +#endif<br>
><br>
> -int main()<br>
> +void basic_test()<br>
> {<br>
>     {<br>
>         int a[] = {0, 1, 2, 3};<br>
> @@ -76,3 +80,179 @@ int main()<br>
>     }<br>
> #endif<br>
> }<br>
> +<br>
> +<br>
> +<br>
> +void test_emplacable_concept() {<br>
> +#if TEST_STD_VER >= 11<br>
> +  int arr1[] = {42};<br>
> +  int arr2[] = {1, 101, 42};<br>
> +  {<br>
> +    using T = EmplaceConstructible<int>;<br>
> +    using It = random_access_iterator<int*>;<br>
> +    {<br>
> +      std::list<T> v(It(arr1), It(std::end(arr1)));<br>
> +      auto I = v.begin();<br>
> +      assert(I->value == 42);<br>
> +    }<br>
> +    {<br>
> +      std::list<T> v(It(arr2), It(std::end(arr2)));<br>
> +      auto I = v.begin();<br>
> +      assert(I->value == 1);<br>
> +      ++I;<br>
> +      assert(I->value == 101);<br>
> +      ++I;<br>
> +      assert(I->value == 42);<br>
> +    }<br>
> +  }<br>
> +  {<br>
> +    using T = EmplaceConstructible<int>;<br>
> +    using It = input_iterator<int*>;<br>
> +    {<br>
> +      std::list<T> v(It(arr1), It(std::end(arr1)));<br>
> +      auto I = v.begin();<br>
> +      assert(I->value == 42);<br>
> +    }<br>
> +    {<br>
> +      std::list<T> v(It(arr2), It(std::end(arr2)));<br>
> +      auto I = v.begin();<br>
> +      //assert(v[0].copied == 0);<br>
> +      assert(I->value == 1);<br>
> +      //assert(v[1].copied == 0);<br>
> +      ++I;<br>
> +      assert(I->value == 101);<br>
> +      ++I;<br>
> +      assert(I->value == 42);<br>
> +    }<br>
> +  }<br>
> +#endif<br>
> +}<br>
> +<br>
> +<br>
> +<br>
> +void test_emplacable_concept_with_<wbr>alloc() {<br>
> +#if TEST_STD_VER >= 11<br>
> +  int arr1[] = {42};<br>
> +  int arr2[] = {1, 101, 42};<br>
> +  {<br>
> +    using T = EmplaceConstructible<int>;<br>
> +    using It = random_access_iterator<int*>;<br>
> +    std::allocator<T> a;<br>
> +    {<br>
> +      std::list<T> v(It(arr1), It(std::end(arr1)), a);<br>
> +      auto I = v.begin();<br>
> +      assert(I->value == 42);<br>
> +    }<br>
> +    {<br>
> +      std::list<T> v(It(arr2), It(std::end(arr2)), a);<br>
> +      auto I = v.begin();<br>
> +      assert(I->value == 1);<br>
> +      ++I;<br>
> +      assert(I->value == 101);<br>
> +      ++I;<br>
> +      assert(I->value == 42);<br>
> +    }<br>
> +  }<br>
> +  {<br>
> +    using T = EmplaceConstructible<int>;<br>
> +    using It = input_iterator<int*>;<br>
> +    std::allocator<T> a;<br>
> +    {<br>
> +      std::list<T> v(It(arr1), It(std::end(arr1)), a);<br>
> +      auto I = v.begin();<br>
> +      assert(I->value == 42);<br>
> +    }<br>
> +    {<br>
> +      std::list<T> v(It(arr2), It(std::end(arr2)), a);<br>
> +      auto I = v.begin();<br>
> +      //assert(v[0].copied == 0);<br>
> +      assert(I->value == 1);<br>
> +      //assert(v[1].copied == 0);<br>
> +      ++I;<br>
> +      assert(I->value == 101);<br>
> +      ++I;<br>
> +      assert(I->value == 42);<br>
> +    }<br>
> +  }<br>
> +#endif<br>
> +}<br>
> +<br>
> +void test_ctor_under_alloc() {<br>
> +#if TEST_STD_VER >= 11<br>
> +  int arr1[] = {42};<br>
> +  int arr2[] = {1, 101, 42};<br>
> +  {<br>
> +    using C = TCT::list<>;<br>
> +    using T = typename C::value_type;<br>
> +    using It = forward_iterator<int*>;<br>
> +    {<br>
> +      ExpectConstructGuard<int&> G(1);<br>
> +      C v(It(arr1), It(std::end(arr1)));<br>
> +    }<br>
> +    {<br>
> +      ExpectConstructGuard<int&> G(3);<br>
> +      C v(It(arr2), It(std::end(arr2)));<br>
> +    }<br>
> +  }<br>
> +  {<br>
> +    using C = TCT::list<>;<br>
> +    using T = typename C::value_type;<br>
> +    using It = input_iterator<int*>;<br>
> +    {<br>
> +      ExpectConstructGuard<int&> G(1);<br>
> +      C v(It(arr1), It(std::end(arr1)));<br>
> +    }<br>
> +    {<br>
> +      ExpectConstructGuard<int&> G(3);<br>
> +      C v(It(arr2), It(std::end(arr2)));<br>
> +    }<br>
> +  }<br>
> +#endif<br>
> +}<br>
> +<br>
> +void test_ctor_under_alloc_with_<wbr>alloc() {<br>
> +#if TEST_STD_VER >= 11<br>
> +  int arr1[] = {42};<br>
> +  int arr2[] = {1, 101, 42};<br>
> +  {<br>
> +    using C = TCT::list<>;<br>
> +    using T = typename C::value_type;<br>
> +    using It = forward_iterator<int*>;<br>
> +    using Alloc = typename C::allocator_type;<br>
> +    Alloc a;<br>
> +    {<br>
> +      ExpectConstructGuard<int&> G(1);<br>
> +      C v(It(arr1), It(std::end(arr1)), a);<br>
> +    }<br>
> +    {<br>
> +      ExpectConstructGuard<int&> G(3);<br>
> +      C v(It(arr2), It(std::end(arr2)), a);<br>
> +    }<br>
> +  }<br>
> +  {<br>
> +    using C = TCT::list<>;<br>
> +    using T = typename C::value_type;<br>
> +    using It = input_iterator<int*>;<br>
> +    using Alloc = typename C::allocator_type;<br>
> +    Alloc a;<br>
> +    {<br>
> +      ExpectConstructGuard<int&> G(1);<br>
> +      C v(It(arr1), It(std::end(arr1)), a);<br>
> +    }<br>
> +    {<br>
> +      ExpectConstructGuard<int&> G(3);<br>
> +      C v(It(arr2), It(std::end(arr2)), a);<br>
> +    }<br>
> +  }<br>
> +#endif<br>
> +}<br>
> +<br>
> +<br>
> +<br>
> +int main() {<br>
> +  basic_test();<br>
> +  test_emplacable_concept();<br>
> +  test_emplacable_concept_with_<wbr>alloc();<br>
> +  test_ctor_under_alloc();<br>
> +  test_ctor_under_alloc_with_<wbr>alloc();<br>
> +}<br>
><br>
> Added: libcxx/trunk/test/std/<wbr>containers/sequences/vector/<wbr>vector.cons/assign_iter_iter.<wbr>pass.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.cons/assign_iter_iter.pass.cpp?rev=315994&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/libcxx/trunk/test/std/<wbr>containers/sequences/vector/<wbr>vector.cons/assign_iter_iter.<wbr>pass.cpp?rev=315994&view=auto</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- libcxx/trunk/test/std/<wbr>containers/sequences/vector/<wbr>vector.cons/assign_iter_iter.<wbr>pass.cpp (added)<br>
> +++ libcxx/trunk/test/std/<wbr>containers/sequences/vector/<wbr>vector.cons/assign_iter_iter.<wbr>pass.cpp Tue Oct 17 06:03:17 2017<br>
> @@ -0,0 +1,76 @@<br>
> +//===------------------------<wbr>------------------------------<wbr>----------------===//<br>
> +//<br>
> +//                     The LLVM Compiler Infrastructure<br>
> +//<br>
> +// This file is dual licensed under the MIT and the University of Illinois Open<br>
> +// Source Licenses. See LICENSE.TXT for details.<br>
> +//<br>
> +//===------------------------<wbr>------------------------------<wbr>----------------===//<br>
> +<br>
> +// <vector><br>
> +<br>
> +// void assign(size_type n, const_reference v);<br>
> +<br>
> +#include <vector><br>
> +#include <algorithm><br>
> +#include <cassert><br>
> +#include <iostream><br>
> +#include "test_macros.h"<br>
> +#include "min_allocator.h"<br>
> +#include "asan_testing.h"<br>
> +#include "test_iterators.h"<br>
> +#if TEST_STD_VER >= 11<br>
> +#include "emplace_constructible.h"<br>
> +#include "container_test_types.h"<br>
> +#endif<br>
> +<br>
> +<br>
> +void test_emplaceable_concept() {<br>
> +#if TEST_STD_VER >= 11<br>
> +  int arr1[] = {42};<br>
> +  int arr2[] = {1, 101, 42};<br>
> +  {<br>
> +    using T = EmplaceConstructibleMoveableAn<wbr>dAssignable<int>;<br>
> +    using It = forward_iterator<int*>;<br>
> +    {<br>
> +      std::vector<T> v;<br>
> +      v.assign(It(arr1), It(std::end(arr1)));<br>
> +      assert(v[0].value == 42);<br>
> +    }<br>
> +    {<br>
> +      std::vector<T> v;<br>
> +      v.assign(It(arr2), It(std::end(arr2)));<br>
> +      assert(v[0].value == 1);<br>
> +      assert(v[1].value == 101);<br>
> +      assert(v[2].value == 42);<br>
> +    }<br>
> +  }<br>
> +  {<br>
> +    using T = EmplaceConstructibleMoveableAn<wbr>dAssignable<int>;<br>
> +    using It = input_iterator<int*>;<br>
> +    {<br>
> +      std::vector<T> v;<br>
> +      v.assign(It(arr1), It(std::end(arr1)));<br>
> +      assert(v[0].copied == 0);<br>
> +      assert(v[0].value == 42);<br>
> +    }<br>
> +    {<br>
> +      std::vector<T> v;<br>
> +      v.assign(It(arr2), It(std::end(arr2)));<br>
> +      //assert(v[0].copied == 0);<br>
> +      assert(v[0].value == 1);<br>
> +      //assert(v[1].copied == 0);<br>
> +      assert(v[1].value == 101);<br>
> +      assert(v[2].copied == 0);<br>
> +      assert(v[2].value == 42);<br>
> +    }<br>
> +  }<br>
> +#endif<br>
> +}<br>
> +<br>
> +<br>
> +<br>
> +int main()<br>
> +{<br>
> +    test_emplaceable_concept();<br>
> +}<br>
><br>
> Modified: libcxx/trunk/test/std/<wbr>containers/sequences/vector/<wbr>vector.cons/construct_iter_<wbr>iter.pass.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp?rev=315994&r1=315993&r2=315994&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/libcxx/trunk/test/std/<wbr>containers/sequences/vector/<wbr>vector.cons/construct_iter_<wbr>iter.pass.cpp?rev=315994&r1=<wbr>315993&r2=315994&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- libcxx/trunk/test/std/<wbr>containers/sequences/vector/<wbr>vector.cons/construct_iter_<wbr>iter.pass.cpp (original)<br>
> +++ libcxx/trunk/test/std/<wbr>containers/sequences/vector/<wbr>vector.cons/construct_iter_<wbr>iter.pass.cpp Tue Oct 17 06:03:17 2017<br>
> @@ -20,40 +20,137 @@<br>
> #include "test_allocator.h"<br>
> #include "min_allocator.h"<br>
> #include "asan_testing.h"<br>
> +#if TEST_STD_VER >= 11<br>
> +#include "emplace_constructible.h"<br>
> +#include "container_test_types.h"<br>
> +#endif<br>
><br>
> template <class C, class Iterator><br>
> -void<br>
> -test(Iterator first, Iterator last)<br>
> -{<br>
> -    C c(first, last);<br>
> -    LIBCPP_ASSERT(c.__invariants()<wbr>);<br>
> -    assert(c.size() == static_cast<std::size_t>(std::<wbr>distance(first, last)));<br>
> -    LIBCPP_ASSERT(is_contiguous_<wbr>container_asan_correct(c));<br>
> -    for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i, ++first)<br>
> -        assert(*i == *first);<br>
> +void test(Iterator first, Iterator last) {<br>
> +  C c(first, last);<br>
> +  LIBCPP_ASSERT(c.__invariants()<wbr>);<br>
> +  assert(c.size() == static_cast<std::size_t>(std::<wbr>distance(first, last)));<br>
> +  LIBCPP_ASSERT(is_contiguous_<wbr>container_asan_correct(c));<br>
> +  for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e;<br>
> +       ++i, ++first)<br>
> +    assert(*i == *first);<br>
> +}<br>
> +<br>
> +static void basic_test_cases() {<br>
> +  int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0};<br>
> +  int* an = a + sizeof(a) / sizeof(a[0]);<br>
> +  test<std::vector<int> >(input_iterator<const int*>(a),<br>
> +                          input_iterator<const int*>(an));<br>
> +  test<std::vector<int> >(forward_iterator<const int*>(a),<br>
> +                          forward_iterator<const int*>(an));<br>
> +  test<std::vector<int> >(bidirectional_iterator<const int*>(a),<br>
> +                          bidirectional_iterator<const int*>(an));<br>
> +  test<std::vector<int> >(random_access_iterator<const int*>(a),<br>
> +                          random_access_iterator<const int*>(an));<br>
> +  test<std::vector<int> >(a, an);<br>
> +<br>
> +  test<std::vector<int, limited_allocator<int, 63> > >(<br>
> +      input_iterator<const int*>(a), input_iterator<const int*>(an));<br>
> +  // Add 1 for implementations that dynamically allocate a container proxy.<br>
> +  test<std::vector<int, limited_allocator<int, 18 + 1> > >(<br>
> +      forward_iterator<const int*>(a), forward_iterator<const int*>(an));<br>
> +  test<std::vector<int, limited_allocator<int, 18 + 1> > >(<br>
> +      bidirectional_iterator<const int*>(a),<br>
> +      bidirectional_iterator<const int*>(an));<br>
> +  test<std::vector<int, limited_allocator<int, 18 + 1> > >(<br>
> +      random_access_iterator<const int*>(a),<br>
> +      random_access_iterator<const int*>(an));<br>
> +  test<std::vector<int, limited_allocator<int, 18 + 1> > >(a, an);<br>
> +#if TEST_STD_VER >= 11<br>
> +  test<std::vector<int, min_allocator<int> > >(input_iterator<const int*>(a),<br>
> +                                               input_iterator<const int*>(an));<br>
> +  test<std::vector<int, min_allocator<int> > >(<br>
> +      forward_iterator<const int*>(a), forward_iterator<const int*>(an));<br>
> +  test<std::vector<int, min_allocator<int> > >(<br>
> +      bidirectional_iterator<const int*>(a),<br>
> +      bidirectional_iterator<const int*>(an));<br>
> +  test<std::vector<int, min_allocator<int> > >(<br>
> +      random_access_iterator<const int*>(a),<br>
> +      random_access_iterator<const int*>(an));<br>
> +  test<std::vector<int> >(a, an);<br>
> +#endif<br>
> }<br>
><br>
> -int main()<br>
> -{<br>
> -    int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0};<br>
> -    int* an = a + sizeof(a)/sizeof(a[0]);<br>
> -    test<std::vector<int> >(input_iterator<const int*>(a), input_iterator<const int*>(an));<br>
> -    test<std::vector<int> >(forward_iterator<const int*>(a), forward_iterator<const int*>(an));<br>
> -    test<std::vector<int> >(bidirectional_iterator<const int*>(a), bidirectional_iterator<const int*>(an));<br>
> -    test<std::vector<int> >(random_access_iterator<const int*>(a), random_access_iterator<const int*>(an));<br>
> -    test<std::vector<int> >(a, an);<br>
> -<br>
> -    test<std::vector<int, limited_allocator<int, 63> > >(input_iterator<const int*>(a), input_iterator<const int*>(an));<br>
> -    // Add 1 for implementations that dynamically allocate a container proxy.<br>
> -    test<std::vector<int, limited_allocator<int, 18 + 1> > >(forward_iterator<const int*>(a), forward_iterator<const int*>(an));<br>
> -    test<std::vector<int, limited_allocator<int, 18 + 1> > >(bidirectional_iterator<const int*>(a), bidirectional_iterator<const int*>(an));<br>
> -    test<std::vector<int, limited_allocator<int, 18 + 1> > >(random_access_iterator<const int*>(a), random_access_iterator<const int*>(an));<br>
> -    test<std::vector<int, limited_allocator<int, 18 + 1> > >(a, an);<br>
> +void emplaceable_concept_tests() {<br>
> #if TEST_STD_VER >= 11<br>
> -    test<std::vector<int, min_allocator<int>> >(input_iterator<const int*>(a), input_iterator<const int*>(an));<br>
> -    test<std::vector<int, min_allocator<int>> >(forward_iterator<const int*>(a), forward_iterator<const int*>(an));<br>
> -    test<std::vector<int, min_allocator<int>> >(bidirectional_iterator<const int*>(a), bidirectional_iterator<const int*>(an));<br>
> -    test<std::vector<int, min_allocator<int>> >(random_access_iterator<const int*>(a), random_access_iterator<const int*>(an));<br>
> -    test<std::vector<int> >(a, an);<br>
> +  int arr1[] = {42};<br>
> +  int arr2[] = {1, 101, 42};<br>
> +  {<br>
> +    using T = EmplaceConstructible<int>;<br>
> +    using It = forward_iterator<int*>;<br>
> +    {<br>
> +      std::vector<T> v(It(arr1), It(std::end(arr1)));<br>
> +      assert(v[0].value == 42);<br>
> +    }<br>
> +    {<br>
> +      std::vector<T> v(It(arr2), It(std::end(arr2)));<br>
> +      assert(v[0].value == 1);<br>
> +      assert(v[1].value == 101);<br>
> +      assert(v[2].value == 42);<br>
> +    }<br>
> +  }<br>
> +  {<br>
> +    using T = EmplaceConstructibleAndMoveIns<wbr>ertable<int>;<br>
> +    using It = input_iterator<int*>;<br>
> +    {<br>
> +      std::vector<T> v(It(arr1), It(std::end(arr1)));<br>
> +      assert(v[0].copied == 0);<br>
> +      assert(v[0].value == 42);<br>
> +    }<br>
> +    {<br>
> +      std::vector<T> v(It(arr2), It(std::end(arr2)));<br>
> +      //assert(v[0].copied == 0);<br>
> +      assert(v[0].value == 1);<br>
> +      //assert(v[1].copied == 0);<br>
> +      assert(v[1].value == 101);<br>
> +      assert(v[2].copied == 0);<br>
> +      assert(v[2].value == 42);<br>
> +    }<br>
> +  }<br>
> #endif<br>
> }<br>
> +<br>
> +void test_ctor_under_alloc() {<br>
> +#if TEST_STD_VER >= 11<br>
> +  int arr1[] = {42};<br>
> +  int arr2[] = {1, 101, 42};<br>
> +  {<br>
> +    using C = TCT::vector<>;<br>
> +    using T = typename C::value_type;<br>
> +    using It = forward_iterator<int*>;<br>
> +    {<br>
> +      ExpectConstructGuard<int&> G(1);<br>
> +      C v(It(arr1), It(std::end(arr1)));<br>
> +    }<br>
> +    {<br>
> +      ExpectConstructGuard<int&> G(3);<br>
> +      C v(It(arr2), It(std::end(arr2)));<br>
> +    }<br>
> +  }<br>
> +  {<br>
> +    using C = TCT::vector<>;<br>
> +    using T = typename C::value_type;<br>
> +    using It = input_iterator<int*>;<br>
> +    {<br>
> +      ExpectConstructGuard<int&> G(1);<br>
> +      C v(It(arr1), It(std::end(arr1)));<br>
> +    }<br>
> +    {<br>
> +      //ExpectConstructGuard<int&> G(3);<br>
> +      //C v(It(arr2), It(std::end(arr2)), a);<br>
> +    }<br>
> +  }<br>
> +#endif<br>
> +}<br>
> +<br>
> +<br>
> +int main() {<br>
> +  basic_test_cases();<br>
> +  emplaceable_concept_tests(); // See PR34898<br>
> +  test_ctor_under_alloc();<br>
> +}<br>
><br>
> Modified: libcxx/trunk/test/std/<wbr>containers/sequences/vector/<wbr>vector.cons/construct_iter_<wbr>iter_alloc.pass.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp?rev=315994&r1=315993&r2=315994&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/libcxx/trunk/test/std/<wbr>containers/sequences/vector/<wbr>vector.cons/construct_iter_<wbr>iter_alloc.pass.cpp?rev=<wbr>315994&r1=315993&r2=315994&<wbr>view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- libcxx/trunk/test/std/<wbr>containers/sequences/vector/<wbr>vector.cons/construct_iter_<wbr>iter_alloc.pass.cpp (original)<br>
> +++ libcxx/trunk/test/std/<wbr>containers/sequences/vector/<wbr>vector.cons/construct_iter_<wbr>iter_alloc.pass.cpp Tue Oct 17 06:03:17 2017<br>
> @@ -21,56 +21,152 @@<br>
> #include "test_allocator.h"<br>
> #include "min_allocator.h"<br>
> #include "asan_testing.h"<br>
> +#if TEST_STD_VER >= 11<br>
> +#include "emplace_constructible.h"<br>
> +#include "container_test_types.h"<br>
> +#endif<br>
><br>
> template <class C, class Iterator, class A><br>
> -void<br>
> -test(Iterator first, Iterator last, const A& a)<br>
> -{<br>
> -    C c(first, last, a);<br>
> -    LIBCPP_ASSERT(c.__invariants()<wbr>);<br>
> -    assert(c.size() == static_cast<std::size_t>(std::<wbr>distance(first, last)));<br>
> -    LIBCPP_ASSERT(is_contiguous_<wbr>container_asan_correct(c));<br>
> -    for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i, ++first)<br>
> -        assert(*i == *first);<br>
> +void test(Iterator first, Iterator last, const A& a) {<br>
> +  C c(first, last, a);<br>
> +  LIBCPP_ASSERT(c.__invariants()<wbr>);<br>
> +  assert(c.size() == static_cast<std::size_t>(std::<wbr>distance(first, last)));<br>
> +  LIBCPP_ASSERT(is_contiguous_<wbr>container_asan_correct(c));<br>
> +  for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e;<br>
> +       ++i, ++first)<br>
> +    assert(*i == *first);<br>
> }<br>
><br>
> #if TEST_STD_VER >= 11<br>
><br>
> template <class T><br>
> -struct implicit_conv_allocator : min_allocator<T><br>
> -{<br>
> -    implicit_conv_allocator(void*) {}<br>
> -    implicit_conv_allocator(const implicit_conv_allocator&) = default;<br>
> +struct implicit_conv_allocator : min_allocator<T> {<br>
> +  implicit_conv_allocator(void*) {}<br>
> +  implicit_conv_allocator(const implicit_conv_allocator&) = default;<br>
><br>
> -    template <class U><br>
> -    implicit_conv_allocator(<wbr>implicit_conv_allocator<U>) {}<br>
> +  template <class U><br>
> +  implicit_conv_allocator(<wbr>implicit_conv_allocator<U>) {}<br>
> };<br>
><br>
> #endif<br>
><br>
> -int main()<br>
> -{<br>
> -    {<br>
> +void basic_tests() {<br>
> +  {<br>
>     int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0};<br>
> -    int* an = a + sizeof(a)/sizeof(a[0]);<br>
> +    int* an = a + sizeof(a) / sizeof(a[0]);<br>
>     std::allocator<int> alloc;<br>
> -    test<std::vector<int> >(input_iterator<const int*>(a), input_iterator<const int*>(an), alloc);<br>
> -    test<std::vector<int> >(forward_iterator<const int*>(a), forward_iterator<const int*>(an), alloc);<br>
> -    test<std::vector<int> >(bidirectional_iterator<const int*>(a), bidirectional_iterator<const int*>(an), alloc);<br>
> -    test<std::vector<int> >(random_access_iterator<const int*>(a), random_access_iterator<const int*>(an), alloc);<br>
> +    test<std::vector<int> >(input_iterator<const int*>(a),<br>
> +                            input_iterator<const int*>(an), alloc);<br>
> +    test<std::vector<int> >(forward_iterator<const int*>(a),<br>
> +                            forward_iterator<const int*>(an), alloc);<br>
> +    test<std::vector<int> >(bidirectional_iterator<const int*>(a),<br>
> +                            bidirectional_iterator<const int*>(an), alloc);<br>
> +    test<std::vector<int> >(random_access_iterator<const int*>(a),<br>
> +                            random_access_iterator<const int*>(an), alloc);<br>
>     test<std::vector<int> >(a, an, alloc);<br>
> -    }<br>
> +  }<br>
> #if TEST_STD_VER >= 11<br>
> -    {<br>
> +  {<br>
>     int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0};<br>
> -    int* an = a + sizeof(a)/sizeof(a[0]);<br>
> +    int* an = a + sizeof(a) / sizeof(a[0]);<br>
>     min_allocator<int> alloc;<br>
> -    test<std::vector<int, min_allocator<int>> >(input_iterator<const int*>(a), input_iterator<const int*>(an), alloc);<br>
> -    test<std::vector<int, min_allocator<int>> >(forward_iterator<const int*>(a), forward_iterator<const int*>(an), alloc);<br>
> -    test<std::vector<int, min_allocator<int>> >(bidirectional_iterator<const int*>(a), bidirectional_iterator<const int*>(an), alloc);<br>
> -    test<std::vector<int, min_allocator<int>> >(random_access_iterator<const int*>(a), random_access_iterator<const int*>(an), alloc);<br>
> -    test<std::vector<int, min_allocator<int>> >(a, an, alloc);<br>
> -    test<std::vector<int, implicit_conv_allocator<int>> >(a, an, nullptr);<br>
> +    test<std::vector<int, min_allocator<int> > >(<br>
> +        input_iterator<const int*>(a), input_iterator<const int*>(an), alloc);<br>
> +    test<std::vector<int, min_allocator<int> > >(<br>
> +        forward_iterator<const int*>(a), forward_iterator<const int*>(an),<br>
> +        alloc);<br>
> +    test<std::vector<int, min_allocator<int> > >(<br>
> +        bidirectional_iterator<const int*>(a),<br>
> +        bidirectional_iterator<const int*>(an), alloc);<br>
> +    test<std::vector<int, min_allocator<int> > >(<br>
> +        random_access_iterator<const int*>(a),<br>
> +        random_access_iterator<const int*>(an), alloc);<br>
> +    test<std::vector<int, min_allocator<int> > >(a, an, alloc);<br>
> +    test<std::vector<int, implicit_conv_allocator<int> > >(a, an, nullptr);<br>
> +  }<br>
> +#endif<br>
> +}<br>
> +<br>
> +void emplaceable_concept_tests() {<br>
> +#if TEST_STD_VER >= 11<br>
> +  int arr1[] = {42};<br>
> +  int arr2[] = {1, 101, 42};<br>
> +  {<br>
> +    using T = EmplaceConstructible<int>;<br>
> +    using It = forward_iterator<int*>;<br>
> +    using Alloc = std::allocator<T>;<br>
> +    Alloc a;<br>
> +    {<br>
> +      std::vector<T> v(It(arr1), It(std::end(arr1)), a);<br>
> +      assert(v[0].value == 42);<br>
> +    }<br>
> +    {<br>
> +      std::vector<T> v(It(arr2), It(std::end(arr2)), a);<br>
> +      assert(v[0].value == 1);<br>
> +      assert(v[1].value == 101);<br>
> +      assert(v[2].value == 42);<br>
> +    }<br>
> +  }<br>
> +  {<br>
> +    using T = EmplaceConstructibleAndMoveIns<wbr>ertable<int>;<br>
> +    using It = input_iterator<int*>;<br>
> +    using Alloc = std::allocator<T>;<br>
> +    Alloc a;<br>
> +    {<br>
> +      std::vector<T> v(It(arr1), It(std::end(arr1)), a);<br>
> +      assert(v[0].copied == 0);<br>
> +      assert(v[0].value == 42);<br>
> +    }<br>
> +    {<br>
> +      std::vector<T> v(It(arr2), It(std::end(arr2)), a);<br>
> +      assert(v[0].value == 1);<br>
> +      assert(v[1].value == 101);<br>
> +      assert(v[2].copied == 0);<br>
> +      assert(v[2].value == 42);<br>
>     }<br>
> +  }<br>
> #endif<br>
> }<br>
> +<br>
> +void test_ctor_under_alloc() {<br>
> +#if TEST_STD_VER >= 11<br>
> +  int arr1[] = {42};<br>
> +  int arr2[] = {1, 101, 42};<br>
> +  {<br>
> +    using C = TCT::vector<>;<br>
> +    using T = typename C::value_type;<br>
> +    using It = forward_iterator<int*>;<br>
> +    using Alloc = typename C::allocator_type;<br>
> +    Alloc a;<br>
> +    {<br>
> +      ExpectConstructGuard<int&> G(1);<br>
> +      C v(It(arr1), It(std::end(arr1)), a);<br>
> +    }<br>
> +    {<br>
> +      ExpectConstructGuard<int&> G(3);<br>
> +      C v(It(arr2), It(std::end(arr2)), a);<br>
> +    }<br>
> +  }<br>
> +  {<br>
> +    using C = TCT::vector<>;<br>
> +    using T = typename C::value_type;<br>
> +    using It = input_iterator<int*>;<br>
> +    using Alloc = typename C::allocator_type;<br>
> +    Alloc a;<br>
> +    {<br>
> +      ExpectConstructGuard<int&> G(1);<br>
> +      C v(It(arr1), It(std::end(arr1)), a);<br>
> +    }<br>
> +    {<br>
> +      //ExpectConstructGuard<int&> G(3);<br>
> +      //C v(It(arr2), It(std::end(arr2)), a);<br>
> +    }<br>
> +  }<br>
> +#endif<br>
> +}<br>
> +<br>
> +int main() {<br>
> +  basic_tests();<br>
> +  emplaceable_concept_tests(); // See PR34898<br>
> +  test_ctor_under_alloc();<br>
> +}<br>
><br>
> Modified: libcxx/trunk/test/support/<wbr>container_test_types.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/container_test_types.h?rev=315994&r1=315993&r2=315994&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/libcxx/trunk/test/<wbr>support/container_test_types.<wbr>h?rev=315994&r1=315993&r2=<wbr>315994&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- libcxx/trunk/test/support/<wbr>container_test_types.h (original)<br>
> +++ libcxx/trunk/test/support/<wbr>container_test_types.h Tue Oct 17 06:03:17 2017<br>
> @@ -234,6 +234,19 @@ inline ConstructController* getConstruct<br>
>   return &c;<br>
> }<br>
><br>
> +template <class ...Args><br>
> +struct ExpectConstructGuard {<br>
> +  ExpectConstructGuard(int N)  {<br>
> +    auto CC = getConstructController();<br>
> +    assert(!CC->unchecked());<br>
> +    CC->expect<Args...>(N);<br>
> +  }<br>
> +<br>
> +  ~ExpectConstructGuard() {<br>
> +    assert(!<wbr>getConstructController()-><wbr>unchecked());<br>
> +  }<br>
> +};<br>
> +<br>
> //===-------------------------<wbr>------------------------------<wbr>---------------===//<br>
> //                       ContainerTestAllocator<br>
> //===-------------------------<wbr>------------------------------<wbr>---------------===//<br>
> @@ -417,7 +430,12 @@ namespace std {<br>
>       return arg.data;<br>
>     }<br>
>   };<br>
> -<br>
> +  template <class T, class Alloc><br>
> +  class vector;<br>
> +  template <class T, class Alloc><br>
> +  class deque;<br>
> +  template <class T, class Alloc><br>
> +  class list;<br>
>   template <class _Key, class _Value, class _Less, class _Alloc><br>
>   class map;<br>
>   template <class _Key, class _Value, class _Less, class _Alloc><br>
> @@ -444,6 +462,13 @@ _LIBCPP_END_NAMESPACE_STD<br>
> // TCT - Test container type<br>
> namespace TCT {<br>
><br>
> +template <class T = CopyInsertable<1>><br>
> +using vector = std::vector<T, ContainerTestAllocator<T, T> >;<br>
> +template <class T = CopyInsertable<1>><br>
> +using deque = std::deque<T, ContainerTestAllocator<T, T> >;<br>
> +template <class T = CopyInsertable<1>><br>
> +using list = std::list<T, ContainerTestAllocator<T, T> >;<br>
> +<br>
> template <class Key = CopyInsertable<1>, class Value = CopyInsertable<2>,<br>
>           class ValueTp = std::pair<const Key, Value> ><br>
> using unordered_map =<br>
> @@ -488,5 +513,4 @@ using multiset =<br>
><br>
> } // end namespace TCT<br>
><br>
> -<br>
> #endif // SUPPORT_CONTAINER_TEST_TYPES_H<br>
><br>
> Added: libcxx/trunk/test/support/<wbr>emplace_constructible.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/emplace_constructible.h?rev=315994&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/libcxx/trunk/test/<wbr>support/emplace_constructible.<wbr>h?rev=315994&view=auto</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- libcxx/trunk/test/support/<wbr>emplace_constructible.h (added)<br>
> +++ libcxx/trunk/test/support/<wbr>emplace_constructible.h Tue Oct 17 06:03:17 2017<br>
> @@ -0,0 +1,74 @@<br>
> +#ifndef TEST_SUPPORT_EMPLACE_<wbr>CONSTRUCTIBLE_H<br>
> +#define TEST_SUPPORT_EMPLACE_<wbr>CONSTRUCTIBLE_H<br>
> +<br>
> +#include "test_macros.h"<br>
> +<br>
> +#if TEST_STD_VER >= 11<br>
> +template <class T><br>
> +struct EmplaceConstructible {<br>
> +  T value;<br>
> +  explicit EmplaceConstructible(T value) : value(value) {}<br>
> +  EmplaceConstructible(<wbr>EmplaceConstructible const&) = delete;<br>
> +};<br>
> +<br>
> +template <class T><br>
> +struct EmplaceConstructibleAndMoveIns<wbr>ertable {<br>
> +  int copied = 0;<br>
> +  T value;<br>
> +  explicit EmplaceConstructibleAndMoveIns<wbr>ertable(T value) : value(value) {}<br>
> +<br>
> +  EmplaceConstructibleAndMoveIns<wbr>ertable(<br>
> +      EmplaceConstructibleAndMoveIns<wbr>ertable&& Other)<br>
> +      : copied(Other.copied + 1), value(std::move(Other.value)) {}<br>
> +};<br>
> +<br>
> +template <class T><br>
> +struct EmplaceConstructibleAndMoveabl<wbr>e {<br>
> +  int copied = 0;<br>
> +  int assigned = 0;<br>
> +  T value;<br>
> +  explicit EmplaceConstructibleAndMoveabl<wbr>e(T value) noexcept : value(value) {}<br>
> +<br>
> +  EmplaceConstructibleAndMoveabl<wbr>e(<wbr>EmplaceConstructibleAndMoveabl<wbr>e&& Other)<br>
> +      noexcept : copied(Other.copied + 1),<br>
> +                 value(std::move(Other.value)) {}<br>
> +<br>
> +  EmplaceConstructibleAndMoveabl<wbr>e&<br>
> +  operator=(<wbr>EmplaceConstructibleAndMoveabl<wbr>e&& Other) noexcept {<br>
> +    copied = Other.copied;<br>
> +    assigned = Other.assigned + 1;<br>
> +    value = std::move(Other.value);<br>
> +    return *this;<br>
> +  }<br>
> +};<br>
> +<br>
> +template <class T><br>
> +struct EmplaceConstructibleMoveableAn<wbr>dAssignable {<br>
> +  int copied = 0;<br>
> +  int assigned = 0;<br>
> +  T value;<br>
> +  explicit EmplaceConstructibleMoveableAn<wbr>dAssignable(T value) noexcept<br>
> +      : value(value) {}<br>
> +<br>
> +  EmplaceConstructibleMoveableAn<wbr>dAssignable(<br>
> +      EmplaceConstructibleMoveableAn<wbr>dAssignable&& Other) noexcept<br>
> +      : copied(Other.copied + 1),<br>
> +        value(std::move(Other.value)) {}<br>
> +<br>
> +  EmplaceConstructibleMoveableAn<wbr>dAssignable&<br>
> +  operator=(<wbr>EmplaceConstructibleMoveableAn<wbr>dAssignable&& Other) noexcept {<br>
> +    copied = Other.copied;<br>
> +    assigned = Other.assigned + 1;<br>
> +    value = std::move(Other.value);<br>
> +    return *this;<br>
> +  }<br>
> +<br>
> +  EmplaceConstructibleMoveableAn<wbr>dAssignable& operator=(T xvalue) {<br>
> +    value = std::move(xvalue);<br>
> +    ++assigned;<br>
> +    return *this;<br>
> +  }<br>
> +};<br>
> +#endif<br>
> +<br>
> +#endif // TEST_SUPPORT_EMPLACE_<wbr>CONSTRUCTIBLE_H<br>
><br>
><br>
> ______________________________<wbr>_________________<br>
> cfe-commits mailing list<br>
> <a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-commits</a><br>
<br>
</div></div></blockquote></div><br></div>