<div dir="ltr">Sorry about that. Fixed in r268839.</div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, May 6, 2016 at 8:32 PM, Vitaly Buka <span dir="ltr"><<a href="mailto:vitalybuka@google.com" target="_blank">vitalybuka@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><a href="http://lab.llvm.org:8011/builders/libcxx-libcxxabi-x86_64-linux-debian-noexceptions/builds/198/" target="_blank">http://lab.llvm.org:8011/builders/libcxx-libcxxabi-x86_64-linux-debian-noexceptions/builds/198/</a> is broken because of this patch<br></div><div class="HOEnZb"><div class="h5"><br><div class="gmail_quote"><div dir="ltr">On Fri, May 6, 2016 at 6:10 PM Eric Fiselier via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: ericwf<br>
Date: Fri May 6 20:04:55 2016<br>
New Revision: 268829<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=268829&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=268829&view=rev</a><br>
Log:<br>
Add <experimental/memory_resource><br>
<br>
Reviewers: mclow.lists, EricWF<br>
<br>
Subscribers: cfe-commits<br>
<br>
Differential Revision: <a href="http://reviews.llvm.org/D20007" rel="noreferrer" target="_blank">http://reviews.llvm.org/D20007</a><br>
<br>
Added:<br>
libcxx/trunk/include/experimental/__memory<br>
libcxx/trunk/include/experimental/memory_resource<br>
libcxx/trunk/src/experimental/memory_resource.cpp<br>
libcxx/trunk/test/libcxx/experimental/memory/<br>
libcxx/trunk/test/libcxx/experimental/memory/memory.polymorphic.allocator.class/<br>
libcxx/trunk/test/libcxx/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/<br>
libcxx/trunk/test/libcxx/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/construct_piecewise_pair.pass.cpp<br>
libcxx/trunk/test/libcxx/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/db_deallocate.pass.cpp<br>
libcxx/trunk/test/libcxx/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/max_size.pass.cpp<br>
libcxx/trunk/test/libcxx/experimental/memory/memory.resource.adaptor/<br>
libcxx/trunk/test/libcxx/experimental/memory/memory.resource.adaptor/memory.resource.adaptor.mem/<br>
libcxx/trunk/test/libcxx/experimental/memory/memory.resource.adaptor/memory.resource.adaptor.mem/db_deallocate.pass.cpp<br>
libcxx/trunk/test/libcxx/experimental/memory/memory.resource.global/<br>
libcxx/trunk/test/libcxx/experimental/memory/memory.resource.global/global_memory_resource_lifetime.pass.cpp<br>
libcxx/trunk/test/libcxx/experimental/memory/memory.resource.global/new_delete_resource_lifetime.pass.cpp<br>
libcxx/trunk/test/libcxx/experimental/memory/memory.resource.synop/<br>
libcxx/trunk/test/libcxx/experimental/memory/memory.resource.synop/version.pass.cpp<br>
libcxx/trunk/test/std/experimental/memory/<br>
libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/<br>
libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.ctor/<br>
libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.ctor/assign.pass.cpp<br>
libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.ctor/copy.pass.cpp<br>
libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.ctor/default.pass.cpp<br>
libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.ctor/memory_resource_convert.pass.cpp<br>
libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.ctor/other_alloc.pass.cpp<br>
libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.eq/<br>
libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.eq/equal.pass.cpp<br>
libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.eq/not_equal.pass.cpp<br>
libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/<br>
libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/allocate.pass.cpp<br>
libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/construct_pair.pass.cpp<br>
libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/construct_pair_const_lvalue_pair.pass.cpp<br>
libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/construct_pair_rvalue.pass.cpp<br>
libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/construct_pair_values.pass.cpp<br>
libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/construct_piecewise_pair.pass.cpp<br>
libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/construct_types.pass.cpp<br>
libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/deallocate.pass.cpp<br>
libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/destroy.pass.cpp<br>
libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/resource.pass.cpp<br>
libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/select_on_container_copy_construction.pass.cpp<br>
libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.overview/<br>
libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.overview/nothing_to_do.pass.cpp<br>
libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/nothing_to_do.pass.cpp<br>
libcxx/trunk/test/std/experimental/memory/memory.resource/<br>
libcxx/trunk/test/std/experimental/memory/memory.resource.adaptor/<br>
libcxx/trunk/test/std/experimental/memory/memory.resource.adaptor/memory.resource.adaptor.ctor/<br>
libcxx/trunk/test/std/experimental/memory/memory.resource.adaptor/memory.resource.adaptor.ctor/alloc_copy.pass.cpp<br>
libcxx/trunk/test/std/experimental/memory/memory.resource.adaptor/memory.resource.adaptor.ctor/alloc_move.pass.cpp<br>
libcxx/trunk/test/std/experimental/memory/memory.resource.adaptor/memory.resource.adaptor.ctor/default.pass.cpp<br>
libcxx/trunk/test/std/experimental/memory/memory.resource.adaptor/memory.resource.adaptor.mem/<br>
libcxx/trunk/test/std/experimental/memory/memory.resource.adaptor/memory.resource.adaptor.mem/do_allocate_and_deallocate.pass.cpp<br>
libcxx/trunk/test/std/experimental/memory/memory.resource.adaptor/memory.resource.adaptor.mem/do_is_equal.pass.cpp<br>
libcxx/trunk/test/std/experimental/memory/memory.resource.adaptor/memory.resource.adaptor.overview/<br>
libcxx/trunk/test/std/experimental/memory/memory.resource.adaptor/memory.resource.adaptor.overview/overview.pass.cpp<br>
libcxx/trunk/test/std/experimental/memory/memory.resource.global/<br>
libcxx/trunk/test/std/experimental/memory/memory.resource.global/default_resource.pass.cpp<br>
libcxx/trunk/test/std/experimental/memory/memory.resource.global/new_delete_resource.pass.cpp<br>
libcxx/trunk/test/std/experimental/memory/memory.resource.global/null_memory_resource.pass.cpp<br>
libcxx/trunk/test/std/experimental/memory/memory.resource.synop/<br>
libcxx/trunk/test/std/experimental/memory/memory.resource.synop/nothing_to_do.pass.cpp<br>
libcxx/trunk/test/std/experimental/memory/memory.resource/construct.fail.cpp<br>
libcxx/trunk/test/std/experimental/memory/memory.resource/memory.resource.eq/<br>
libcxx/trunk/test/std/experimental/memory/memory.resource/memory.resource.eq/equal.pass.cpp<br>
libcxx/trunk/test/std/experimental/memory/memory.resource/memory.resource.eq/not_equal.pass.cpp<br>
libcxx/trunk/test/std/experimental/memory/memory.resource/memory.resource.overview/<br>
libcxx/trunk/test/std/experimental/memory/memory.resource/memory.resource.overview/nothing_to_do.pass.cpp<br>
libcxx/trunk/test/std/experimental/memory/memory.resource/memory.resource.priv/<br>
libcxx/trunk/test/std/experimental/memory/memory.resource/memory.resource.priv/protected_members.fail.cpp<br>
libcxx/trunk/test/std/experimental/memory/memory.resource/memory.resource.public/<br>
libcxx/trunk/test/std/experimental/memory/memory.resource/memory.resource.public/allocate.pass.cpp<br>
libcxx/trunk/test/std/experimental/memory/memory.resource/memory.resource.public/deallocate.pass.cpp<br>
libcxx/trunk/test/std/experimental/memory/memory.resource/memory.resource.public/dtor.pass.cpp<br>
libcxx/trunk/test/std/experimental/memory/memory.resource/memory.resource.public/is_equal.pass.cpp<br>
libcxx/trunk/test/std/experimental/memory/nothing_to_do.pass.cpp<br>
libcxx/trunk/test/support/test_memory_resource.hpp<br>
libcxx/trunk/test/support/type_id.h<br>
libcxx/trunk/test/support/uses_alloc_types.hpp<br>
Removed:<br>
libcxx/trunk/src/experimental/placeholder.cpp<br>
Modified:<br>
libcxx/trunk/include/exception<br>
libcxx/trunk/include/experimental/__config<br>
<br>
Modified: libcxx/trunk/include/exception<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/exception?rev=268829&r1=268828&r2=268829&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/exception?rev=268829&r1=268828&r2=268829&view=diff</a><br>
==============================================================================<br>
--- libcxx/trunk/include/exception (original)<br>
+++ libcxx/trunk/include/exception Fri May 6 20:04:55 2016<br>
@@ -80,6 +80,10 @@ template <class E> void rethrow_if_neste<br>
#include <__config><br>
#include <cstddef><br>
#include <type_traits><br>
+#if defined(_LIBCPP_HAS_NO_EXCEPTIONS)<br>
+#include <cstdio><br>
+#include <cstdlib><br>
+#endif<br>
<br>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)<br>
#pragma GCC system_header<br>
@@ -251,4 +255,19 @@ rethrow_if_nested(const _Ep&, typename e<br>
<br>
} // std<br>
<br>
+_LIBCPP_BEGIN_NAMESPACE_STD<br>
+<br>
+template <class _Exception><br>
+_LIBCPP_INLINE_VISIBILITY<br>
+inline void __libcpp_throw(_Exception const& __e) {<br>
+#ifndef _LIBCPP_HAS_NO_EXCEPTIONS<br>
+ throw __e;<br>
+#else<br>
+ _VSTD::fprintf(stderr, "%s\n", __e.what());<br>
+ _VSTD::abort();<br>
+#endif<br>
+}<br>
+<br>
+_LIBCPP_END_NAMESPACE_STD<br>
+<br>
#endif // _LIBCPP_EXCEPTION<br>
<br>
Modified: libcxx/trunk/include/experimental/__config<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/__config?rev=268829&r1=268828&r2=268829&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/__config?rev=268829&r1=268828&r2=268829&view=diff</a><br>
==============================================================================<br>
--- libcxx/trunk/include/experimental/__config (original)<br>
+++ libcxx/trunk/include/experimental/__config Fri May 6 20:04:55 2016<br>
@@ -25,6 +25,10 @@<br>
#define _LIBCPP_END_NAMESPACE_LFTS } } }<br>
#define _VSTD_LFTS _VSTD_EXPERIMENTAL::fundamentals_v1<br>
<br>
+#define _LIBCPP_BEGIN_NAMESPACE_LFTS_PMR _LIBCPP_BEGIN_NAMESPACE_LFTS namespace pmr {<br>
+#define _LIBCPP_END_NAMESPACE_LFTS_PMR _LIBCPP_END_NAMESPACE_LFTS }<br>
+#define _VSTD_LFTS_PMR _VSTD_LFTS::pmr<br>
+<br>
#define _LIBCPP_BEGIN_NAMESPACE_CHRONO_LFTS _LIBCPP_BEGIN_NAMESPACE_STD \<br>
namespace chrono { namespace experimental { inline namespace fundamentals_v1 {<br>
#define _LIBCPP_END_NAMESPACE_CHRONO_LFTS _LIBCPP_END_NAMESPACE_STD } } }<br>
<br>
Added: libcxx/trunk/include/experimental/__memory<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/__memory?rev=268829&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/__memory?rev=268829&view=auto</a><br>
==============================================================================<br>
--- libcxx/trunk/include/experimental/__memory (added)<br>
+++ libcxx/trunk/include/experimental/__memory Fri May 6 20:04:55 2016<br>
@@ -0,0 +1,90 @@<br>
+// -*- C++ -*-<br>
+//===----------------------------------------------------------------------===//<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>
+//===----------------------------------------------------------------------===//<br>
+<br>
+#ifndef _LIBCPP_EXPERIMENTAL___MEMORY<br>
+#define _LIBCPP_EXPERIMENTAL___MEMORY<br>
+<br>
+#include <experimental/__config><br>
+#include <experimental/utility> // for erased_type<br>
+#include <__functional_base><br>
+#include <type_traits><br>
+<br>
+_LIBCPP_BEGIN_NAMESPACE_LFTS<br>
+<br>
+template <<br>
+ class _Tp, class _Alloc<br>
+ , bool = uses_allocator<_Tp, _Alloc>::value<br>
+ , bool = __has_allocator_type<_Tp>::value<br>
+ ><br>
+struct __lfts_uses_allocator : public false_type {};<br>
+<br>
+template <class _Tp, class _Alloc><br>
+struct __lfts_uses_allocator<_Tp, _Alloc, false, false> : public false_type {};<br>
+<br>
+template <class _Tp, class _Alloc, bool HasAlloc><br>
+struct __lfts_uses_allocator<_Tp, _Alloc, true, HasAlloc> : public true_type {};<br>
+<br>
+template <class _Tp, class _Alloc><br>
+struct __lfts_uses_allocator<_Tp, _Alloc, false, true><br>
+ : public integral_constant<bool<br>
+ , is_convertible<_Alloc, typename _Tp::allocator_type>::value<br>
+ || is_same<erased_type, typename _Tp::allocator_type>::value<br>
+ ><br>
+{};<br>
+<br>
+template <bool _UsesAlloc, class _Tp, class _Alloc, class ..._Args><br>
+struct __lfts_uses_alloc_ctor_imp<br>
+{<br>
+ static const int value = 0;<br>
+};<br>
+<br>
+template <class _Tp, class _Alloc, class ..._Args><br>
+struct __lfts_uses_alloc_ctor_imp<true, _Tp, _Alloc, _Args...><br>
+{<br>
+ static const bool __ic_first<br>
+ = is_constructible<_Tp, allocator_arg_t, _Alloc, _Args...>::value;<br>
+<br>
+ static const bool __ic_second =<br>
+ conditional<<br>
+ __ic_first,<br>
+ false_type,<br>
+ is_constructible<_Tp, _Args..., _Alloc><br>
+ >::type::value;<br>
+<br>
+ static_assert(__ic_first || __ic_second,<br>
+ "Request for uses allocator construction is ill-formed");<br>
+<br>
+ static const int value = __ic_first ? 1 : 2;<br>
+};<br>
+<br>
+template <class _Tp, class _Alloc, class ..._Args><br>
+struct __lfts_uses_alloc_ctor<br>
+ : integral_constant<int,<br>
+ __lfts_uses_alloc_ctor_imp<<br>
+ __lfts_uses_allocator<_Tp, _Alloc>::value<br>
+ , _Tp, _Alloc, _Args...<br>
+ >::value<br>
+ ><br>
+{};<br>
+<br>
+template <class _Tp, class _Alloc, class ..._Args><br>
+inline _LIBCPP_INLINE_VISIBILITY<br>
+void __lfts_user_alloc_construct(<br>
+ _Tp * __store, const _Alloc & __a, _Args &&... __args)<br>
+{<br>
+ _VSTD::__user_alloc_construct_impl(<br>
+ typename __lfts_uses_alloc_ctor<_Tp, _Alloc, _Args...>::type()<br>
+ , __store, __a, _VSTD::forward<_Args>(__args)...<br>
+ );<br>
+}<br>
+<br>
+_LIBCPP_END_NAMESPACE_LFTS<br>
+<br>
+#endif /* _LIBCPP_EXPERIMENTAL___MEMORY */<br>
<br>
Added: libcxx/trunk/include/experimental/memory_resource<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/memory_resource?rev=268829&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/memory_resource?rev=268829&view=auto</a><br>
==============================================================================<br>
--- libcxx/trunk/include/experimental/memory_resource (added)<br>
+++ libcxx/trunk/include/experimental/memory_resource Fri May 6 20:04:55 2016<br>
@@ -0,0 +1,422 @@<br>
+// -*- C++ -*-<br>
+//===------------------------ memory_resource -----------------------------===//<br>
+//<br>
+// The LLVM Compiler Infrastructure<br>
+//<br>
+// This file is distributed under the University of Illinois Open Source<br>
+// License. See LICENSE.TXT for details.<br>
+//<br>
+//===----------------------------------------------------------------------===//<br>
+<br>
+#ifndef _LIBCPP_EXPERIMENTAL_MEMORY_RESOURCE<br>
+#define _LIBCPP_EXPERIMENTAL_MEMORY_RESOURCE<br>
+<br>
+/**<br>
+ experimental/memory_resource synopsis<br>
+<br>
+// C++1y<br>
+<br>
+namespace std {<br>
+namespace experimental {<br>
+inline namespace fundamentals_v1 {<br>
+namespace pmr {<br>
+<br>
+ class memory_resource;<br>
+<br>
+ bool operator==(const memory_resource& a,<br>
+ const memory_resource& b) noexcept;<br>
+ bool operator!=(const memory_resource& a,<br>
+ const memory_resource& b) noexcept;<br>
+<br>
+ template <class Tp> class polymorphic_allocator;<br>
+<br>
+ template <class T1, class T2><br>
+ bool operator==(const polymorphic_allocator<T1>& a,<br>
+ const polymorphic_allocator<T2>& b) noexcept;<br>
+ template <class T1, class T2><br>
+ bool operator!=(const polymorphic_allocator<T1>& a,<br>
+ const polymorphic_allocator<T2>& b) noexcept;<br>
+<br>
+ // The name resource_adaptor_imp is for exposition only.<br>
+ template <class Allocator> class resource_adaptor_imp;<br>
+<br>
+ template <class Allocator><br>
+ using resource_adaptor = resource_adaptor_imp<<br>
+ allocator_traits<Allocator>::rebind_alloc<char>>;<br>
+<br>
+ // Global memory resources<br>
+ memory_resource* new_delete_resource() noexcept;<br>
+ memory_resource* null_memory_resource() noexcept;<br>
+<br>
+ // The default memory resource<br>
+ memory_resource* set_default_resource(memory_resource* r) noexcept;<br>
+ memory_resource* get_default_resource() noexcept;<br>
+<br>
+ // Standard memory resources<br>
+ struct pool_options;<br>
+ class synchronized_pool_resource;<br>
+ class unsynchronized_pool_resource;<br>
+ class monotonic_buffer_resource;<br>
+<br>
+} // namespace pmr<br>
+} // namespace fundamentals_v1<br>
+} // namespace experimental<br>
+} // namespace std<br>
+<br>
+ */<br>
+<br>
+#include <experimental/__config><br>
+#include <experimental/__memory><br>
+#include <limits><br>
+#include <memory><br>
+#include <new><br>
+#include <stdexcept><br>
+#include <tuple><br>
+#include <type_traits><br>
+#include <utility><br>
+#include <cstddef><br>
+#include <cstdlib><br>
+#include <__debug><br>
+<br>
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)<br>
+#pragma GCC system_header<br>
+#endif<br>
+<br>
+_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR<br>
+<br>
+// Round __s up to next multiple of __a.<br>
+inline _LIBCPP_INLINE_VISIBILITY<br>
+size_t __aligned_allocation_size(size_t __s, size_t __a) _NOEXCEPT<br>
+{<br>
+ _LIBCPP_ASSERT(__s + __a > __s, "aligned allocation size overflows");<br>
+ return (__s + __a - 1) & ~(__a - 1);<br>
+}<br>
+<br>
+// 8.5, memory.resource<br>
+class _LIBCPP_TYPE_VIS_ONLY memory_resource<br>
+{<br>
+ static const size_t __max_align = alignof(max_align_t);<br>
+<br>
+// 8.5.2, memory.resource.public<br>
+public:<br>
+ virtual ~memory_resource() = default;<br>
+<br>
+ _LIBCPP_INLINE_VISIBILITY<br>
+ void* allocate(size_t __bytes, size_t __align = __max_align)<br>
+ { return do_allocate(__bytes, __align); }<br>
+<br>
+ _LIBCPP_INLINE_VISIBILITY<br>
+ void deallocate(void * __p, size_t __bytes, size_t __align = __max_align)<br>
+ { do_deallocate(__p, __bytes, __align); }<br>
+<br>
+ _LIBCPP_INLINE_VISIBILITY<br>
+ bool is_equal(memory_resource const & __other) const _NOEXCEPT<br>
+ { return do_is_equal(__other); }<br>
+<br>
+// 8.5.3, memory.resource.priv<br>
+protected:<br>
+ virtual void* do_allocate(size_t, size_t) = 0;<br>
+ virtual void do_deallocate(void*, size_t, size_t) = 0;<br>
+ virtual bool do_is_equal(memory_resource const &) const _NOEXCEPT = 0;<br>
+};<br>
+<br>
+// 8.5.4, memory.resource.eq<br>
+inline _LIBCPP_INLINE_VISIBILITY<br>
+bool operator==(memory_resource const & __lhs,<br>
+ memory_resource const & __rhs) _NOEXCEPT<br>
+{<br>
+ return &__lhs == &__rhs || __lhs.is_equal(__rhs);<br>
+}<br>
+<br>
+inline _LIBCPP_INLINE_VISIBILITY<br>
+bool operator!=(memory_resource const & __lhs,<br>
+ memory_resource const & __rhs) _NOEXCEPT<br>
+{<br>
+ return !(__lhs == __rhs);<br>
+}<br>
+<br>
+_LIBCPP_FUNC_VIS<br>
+memory_resource * new_delete_resource() _NOEXCEPT;<br>
+<br>
+_LIBCPP_FUNC_VIS<br>
+memory_resource * null_memory_resource() _NOEXCEPT;<br>
+<br>
+_LIBCPP_FUNC_VIS<br>
+memory_resource * get_default_resource() _NOEXCEPT;<br>
+<br>
+_LIBCPP_FUNC_VIS<br>
+memory_resource * set_default_resource(memory_resource * __new_res) _NOEXCEPT;<br>
+<br>
+// 8.6, memory.polymorphic.allocator.class<br>
+<br>
+// 8.6.1, memory.polymorphic.allocator.overview<br>
+template <class _ValueType><br>
+class _LIBCPP_TYPE_VIS_ONLY polymorphic_allocator<br>
+{<br>
+public:<br>
+ typedef _ValueType value_type;<br>
+<br>
+ // 8.6.2, memory.polymorphic.allocator.ctor<br>
+ _LIBCPP_INLINE_VISIBILITY<br>
+ polymorphic_allocator() _NOEXCEPT<br>
+ : __res_(_VSTD_LFTS_PMR::get_default_resource())<br>
+ {}<br>
+<br>
+ _LIBCPP_INLINE_VISIBILITY<br>
+ polymorphic_allocator(memory_resource * __r) _NOEXCEPT<br>
+ : __res_(__r)<br>
+ {}<br>
+<br>
+ polymorphic_allocator(polymorphic_allocator const &) = default;<br>
+<br>
+ template <class _Tp><br>
+ _LIBCPP_INLINE_VISIBILITY<br>
+ polymorphic_allocator(polymorphic_allocator<_Tp> const & __other) _NOEXCEPT<br>
+ : __res_(__other.resource())<br>
+ {}<br>
+<br>
+ polymorphic_allocator &<br>
+ operator=(polymorphic_allocator const &) = default;<br>
+<br>
+ // 8.6.3, memory.polymorphic.allocator.mem<br>
+ _LIBCPP_INLINE_VISIBILITY<br>
+ _ValueType* allocate(size_t __n) {<br>
+ if (__n > max_size()) {<br>
+ __libcpp_throw(length_error(<br>
+ "std::experimental::pmr::polymorphic_allocator<T>::allocate(size_t n)"<br>
+ " 'n' exceeds maximum supported size"));<br>
+ }<br>
+ return static_cast<_ValueType*>(<br>
+ __res_->allocate(__n * sizeof(_ValueType), alignof(_ValueType))<br>
+ );<br>
+ }<br>
+<br>
+ _LIBCPP_INLINE_VISIBILITY<br>
+ void deallocate(_ValueType * __p, size_t __n) _NOEXCEPT {<br>
+ _LIBCPP_ASSERT(__n <= max_size(),<br>
+ "deallocate called for size which exceeds max_size()");<br>
+ __res_->deallocate(__p, __n * sizeof(_ValueType), alignof(_ValueType));<br>
+ }<br>
+<br>
+ template <class _Tp, class ..._Ts><br>
+ _LIBCPP_INLINE_VISIBILITY<br>
+ void construct(_Tp* __p, _Ts &&... __args)<br>
+ {<br>
+ _VSTD_LFTS::__lfts_user_alloc_construct(<br>
+ __p, resource(), _VSTD::forward<_Ts>(__args)...<br>
+ );<br>
+ }<br>
+<br>
+ template <class _T1, class _T2, class ..._Args1, class ..._Args2><br>
+ _LIBCPP_INLINE_VISIBILITY<br>
+ void construct(pair<_T1, _T2>* __p, piecewise_construct_t,<br>
+ tuple<_Args1...> __x, tuple<_Args2...> __y)<br>
+ {<br>
+ ::new ((void*)__p) pair<_T1, _T2>(piecewise_construct<br>
+ , __transform_tuple(<br>
+ typename __lfts_uses_alloc_ctor<<br>
+ _T1, memory_resource*, _Args1...<br>
+ >::type()<br>
+ , _VSTD::move(__x)<br>
+ , typename __make_tuple_indices<sizeof...(_Args1)>::type{}<br>
+ )<br>
+ , __transform_tuple(<br>
+ typename __lfts_uses_alloc_ctor<<br>
+ _T2, memory_resource*, _Args2...<br>
+ >::type()<br>
+ , _VSTD::move(__y)<br>
+ , typename __make_tuple_indices<sizeof...(_Args2)>::type{}<br>
+ )<br>
+ );<br>
+ }<br>
+<br>
+ template <class _T1, class _T2><br>
+ _LIBCPP_INLINE_VISIBILITY<br>
+ void construct(pair<_T1, _T2>* __p) {<br>
+ construct(__p, piecewise_construct, tuple<>(), tuple<>());<br>
+ }<br>
+<br>
+ template <class _T1, class _T2, class _Up, class _Vp><br>
+ _LIBCPP_INLINE_VISIBILITY<br>
+ void construct(pair<_T1, _T2> * __p, _Up && __u, _Vp && __v) {<br>
+ construct(__p, piecewise_construct<br>
+ , _VSTD::forward_as_tuple(_VSTD::forward<_Up>(__u))<br>
+ , _VSTD::forward_as_tuple(_VSTD::forward<_Vp>(__v)));<br>
+ }<br>
+<br>
+ template <class _T1, class _T2, class _U1, class _U2><br>
+ _LIBCPP_INLINE_VISIBILITY<br>
+ void construct(pair<_T1, _T2> * __p, pair<_U1, _U2> const & __pr) {<br>
+ construct(__p, piecewise_construct<br>
+ , _VSTD::forward_as_tuple(__pr.first)<br>
+ , _VSTD::forward_as_tuple(__pr.second));<br>
+ }<br>
+<br>
+ template <class _T1, class _T2, class _U1, class _U2><br>
+ _LIBCPP_INLINE_VISIBILITY<br>
+ void construct(pair<_T1, _T2> * __p, pair<_U1, _U2> && __pr){<br>
+ construct(__p, piecewise_construct<br>
+ , _VSTD::forward_as_tuple(_VSTD::forward<_U1>(__pr.first))<br>
+ , _VSTD::forward_as_tuple(_VSTD::forward<_U2>(__pr.second)));<br>
+ }<br>
+<br>
+ template <class _Tp><br>
+ _LIBCPP_INLINE_VISIBILITY<br>
+ void destroy(_Tp * __p) _NOEXCEPT<br>
+ { __p->~_Tp(); }<br>
+<br>
+ _LIBCPP_INLINE_VISIBILITY<br>
+ size_t max_size() const _NOEXCEPT<br>
+ { return numeric_limits<size_t>::max() / sizeof(value_type); }<br>
+<br>
+ _LIBCPP_INLINE_VISIBILITY<br>
+ polymorphic_allocator<br>
+ select_on_container_copy_construction() const _NOEXCEPT<br>
+ { return polymorphic_allocator(); }<br>
+<br>
+ _LIBCPP_INLINE_VISIBILITY<br>
+ memory_resource * resource() const _NOEXCEPT<br>
+ { return __res_; }<br>
+<br>
+private:<br>
+ template <class ..._Args, size_t ..._Idx><br>
+ _LIBCPP_INLINE_VISIBILITY<br>
+ tuple<_Args&&...><br>
+ __transform_tuple(integral_constant<int, 0>, tuple<_Args...>&& __t,<br>
+ __tuple_indices<_Idx...>) const<br>
+ {<br>
+ return _VSTD::forward_as_tuple(_VSTD::get<_Idx>(_VSTD::move(__t))...);<br>
+ }<br>
+<br>
+ template <class ..._Args, size_t ..._Idx><br>
+ _LIBCPP_INLINE_VISIBILITY<br>
+ tuple<allocator_arg_t const&, memory_resource*, _Args&&...><br>
+ __transform_tuple(integral_constant<int, 1>, tuple<_Args...> && __t,<br>
+ __tuple_indices<_Idx...>) const<br>
+ {<br>
+ using _Tup = tuple<allocator_arg_t const&, memory_resource*, _Args&&...>;<br>
+ return _Tup(allocator_arg, resource(),<br>
+ _VSTD::get<_Idx>(_VSTD::move(__t))...);<br>
+ }<br>
+<br>
+ template <class ..._Args, size_t ..._Idx><br>
+ _LIBCPP_INLINE_VISIBILITY<br>
+ tuple<_Args&&..., memory_resource*><br>
+ __transform_tuple(integral_constant<int, 2>, tuple<_Args...> && __t,<br>
+ __tuple_indices<_Idx...>) const<br>
+ {<br>
+ using _Tup = tuple<_Args&&..., memory_resource*>;<br>
+ return _Tup(_VSTD::get<_Idx>(_VSTD::move(__t))..., resource());<br>
+ }<br>
+<br>
+ memory_resource * __res_;<br>
+};<br>
+<br>
+// 8.6.4, memory.polymorphic.allocator.eq<br>
+<br>
+template <class _Tp, class _Up><br>
+inline _LIBCPP_INLINE_VISIBILITY<br>
+bool operator==(polymorphic_allocator<_Tp> const & __lhs,<br>
+ polymorphic_allocator<_Up> const & __rhs) _NOEXCEPT<br>
+{<br>
+ return *__lhs.resource() == *__rhs.resource();<br>
+}<br>
+<br>
+template <class _Tp, class _Up><br>
+inline _LIBCPP_INLINE_VISIBILITY<br>
+bool operator!=(polymorphic_allocator<_Tp> const & __lhs,<br>
+ polymorphic_allocator<_Up> const & __rhs) _NOEXCEPT<br>
+{<br>
+ return !(__lhs == __rhs);<br>
+}<br>
+<br>
+// 8.7, memory.resource.adaptor<br>
+<br>
+// 8.7.1, memory.resource.adaptor.overview<br>
+template <class _CharAlloc><br>
+class _LIBCPP_TYPE_VIS_ONLY __resource_adaptor_imp<br>
+ : public memory_resource<br>
+{<br>
+ using _CTraits = allocator_traits<_CharAlloc>;<br>
+ static_assert(is_same<typename _CTraits::value_type, char>::value<br>
+ && is_same<typename _CTraits::pointer, char*>::value<br>
+ && is_same<typename _CTraits::void_pointer, void*>::value, "");<br>
+<br>
+ static const size_t _MaxAlign = alignof(max_align_t);<br>
+<br>
+ using _Alloc = typename _CTraits::template rebind_alloc<<br>
+ typename aligned_storage<_MaxAlign, _MaxAlign>::type<br>
+ >;<br>
+<br>
+ using _ValueType = typename _Alloc::value_type;<br>
+<br>
+ _Alloc __alloc_;<br>
+<br>
+public:<br>
+ typedef _CharAlloc allocator_type;<br>
+<br>
+ __resource_adaptor_imp() = default;<br>
+ __resource_adaptor_imp(__resource_adaptor_imp const &) = default;<br>
+ __resource_adaptor_imp(__resource_adaptor_imp &&) = default;<br>
+<br>
+ // 8.7.2, memory.resource.adaptor.ctor<br>
+<br>
+ _LIBCPP_INLINE_VISIBILITY<br>
+ explicit __resource_adaptor_imp(allocator_type const & __a)<br>
+ : __alloc_(__a)<br>
+ {}<br>
+<br>
+ _LIBCPP_INLINE_VISIBILITY<br>
+ explicit __resource_adaptor_imp(allocator_type && __a)<br>
+ : __alloc_(_VSTD::move(__a))<br>
+ {}<br>
+<br>
+ __resource_adaptor_imp &<br>
+ operator=(__resource_adaptor_imp const &) = default;<br>
+<br>
+ _LIBCPP_INLINE_VISIBILITY<br>
+ allocator_type get_allocator() const<br>
+ { return __alloc_; }<br>
+<br>
+// 8.7.3, memory.resource.adaptor.mem<br>
+protected:<br>
+ virtual void * do_allocate(size_t __bytes, size_t)<br>
+ {<br>
+ if (__bytes > __max_size()) {<br>
+ __libcpp_throw(length_error(<br>
+ "std::experimental::pmr::resource_adaptor<T>::do_allocate(size_t bytes, size_t align)"<br>
+ " 'bytes' exceeds maximum supported size"));<br>
+ }<br>
+ size_t __s = __aligned_allocation_size(__bytes, _MaxAlign) / _MaxAlign;<br>
+ return __alloc_.allocate(__s);<br>
+ }<br>
+<br>
+ virtual void do_deallocate(void * __p, size_t __bytes, size_t)<br>
+ {<br>
+ _LIBCPP_ASSERT(__bytes <= __max_size(),<br>
+ "do_deallocate called for size which exceeds the maximum allocation size");<br>
+ size_t __s = __aligned_allocation_size(__bytes, _MaxAlign) / _MaxAlign;<br>
+ __alloc_.deallocate((_ValueType*)__p, __s);<br>
+ }<br>
+<br>
+ virtual bool do_is_equal(memory_resource const & __other) const _NOEXCEPT {<br>
+ __resource_adaptor_imp const * __p<br>
+ = dynamic_cast<__resource_adaptor_imp const *>(&__other);<br>
+ return __p ? __alloc_ == __p->__alloc_ : false;<br>
+ }<br>
+<br>
+private:<br>
+ _LIBCPP_INLINE_VISIBILITY<br>
+ size_t __max_size() const _NOEXCEPT {<br>
+ return numeric_limits<size_t>::max() - _MaxAlign;<br>
+ }<br>
+};<br>
+<br>
+template <class _Alloc><br>
+using resource_adaptor = __resource_adaptor_imp<<br>
+ typename allocator_traits<_Alloc>::template rebind_alloc<char><br>
+ >;<br>
+<br>
+_LIBCPP_END_NAMESPACE_LFTS_PMR<br>
+<br>
+#endif /* _LIBCPP_EXPERIMENTAL_MEMORY_RESOURCE */<br>
<br>
Added: libcxx/trunk/src/experimental/memory_resource.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/memory_resource.cpp?rev=268829&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/memory_resource.cpp?rev=268829&view=auto</a><br>
==============================================================================<br>
--- libcxx/trunk/src/experimental/memory_resource.cpp (added)<br>
+++ libcxx/trunk/src/experimental/memory_resource.cpp Fri May 6 20:04:55 2016<br>
@@ -0,0 +1,129 @@<br>
+//===------------------------ memory_resource.cpp -------------------------===//<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>
+//===----------------------------------------------------------------------===//<br>
+<br>
+#include "experimental/memory_resource"<br>
+<br>
+#ifndef _LIBCPP_HAS_NO_ATOMIC_HEADER<br>
+#include "atomic"<br>
+#else<br>
+#include "mutex"<br>
+#endif<br>
+<br>
+_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR<br>
+<br>
+// memory_resource<br>
+<br>
+//memory_resource::~memory_resource() {}<br>
+<br>
+// new_delete_resource()<br>
+<br>
+class _LIBCPP_TYPE_VIS_ONLY __new_delete_memory_resource_imp<br>
+ : public memory_resource<br>
+{<br>
+public:<br>
+ ~__new_delete_memory_resource_imp() = default;<br>
+<br>
+protected:<br>
+ virtual void* do_allocate(size_t __size, size_t __align)<br>
+ { return __allocate(__size); }<br>
+<br>
+ virtual void do_deallocate(void * __p, size_t, size_t)<br>
+ { __deallocate(__p); }<br>
+<br>
+ virtual bool do_is_equal(memory_resource const & __other) const _NOEXCEPT<br>
+ { return &__other == this; }<br>
+};<br>
+<br>
+// null_memory_resource()<br>
+<br>
+class _LIBCPP_TYPE_VIS_ONLY __null_memory_resource_imp<br>
+ : public memory_resource<br>
+{<br>
+public:<br>
+ ~__null_memory_resource_imp() = default;<br>
+<br>
+protected:<br>
+ virtual void* do_allocate(size_t, size_t) {<br>
+#ifndef _LIBCPP_HAS_NO_EXCEPTIONS<br>
+ throw std::bad_alloc();<br>
+#else<br>
+ abort();<br>
+#endif<br>
+ }<br>
+ virtual void do_deallocate(void *, size_t, size_t) {}<br>
+ virtual bool do_is_equal(memory_resource const & __other) const _NOEXCEPT<br>
+ { return &__other == this; }<br>
+};<br>
+<br>
+union ResourceInitHelper {<br>
+ struct {<br>
+ __new_delete_memory_resource_imp new_delete_res;<br>
+ __null_memory_resource_imp null_res;<br>
+ } resources;<br>
+ char dummy;<br>
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 ResourceInitHelper() : resources() {}<br>
+ ~ResourceInitHelper() {}<br>
+};<br>
+// When compiled in C++14 this initialization should be a constant expression.<br>
+// Only in C++11 is "init_priority" needed to ensure initialization order.<br>
+ResourceInitHelper res_init __attribute__((init_priority (101)));<br>
+<br>
+memory_resource * new_delete_resource() _NOEXCEPT {<br>
+ return &res_init.resources.new_delete_res;<br>
+}<br>
+<br>
+memory_resource * null_memory_resource() _NOEXCEPT {<br>
+ return &res_init.resources.null_res;<br>
+}<br>
+<br>
+// default_memory_resource()<br>
+<br>
+static memory_resource *<br>
+__default_memory_resource(bool set = false, memory_resource * new_res = nullptr) _NOEXCEPT<br>
+{<br>
+#ifndef _LIBCPP_HAS_NO_ATOMIC_HEADER<br>
+ static atomic<memory_resource*> __res =<br>
+ ATOMIC_VAR_INIT(&res_init.resources.new_delete_res);<br>
+ if (set) {<br>
+ new_res = new_res ? new_res : new_delete_resource();<br>
+ // TODO: Can a weaker ordering be used?<br>
+ return _VSTD::atomic_exchange_explicit(<br>
+ &__res, new_res, memory_order::memory_order_acq_rel);<br>
+ }<br>
+ else {<br>
+ return _VSTD::atomic_load_explicit(<br>
+ &__res, memory_order::memory_order_acquire);<br>
+ }<br>
+#else<br>
+ static memory_resource * res = &res_init.resources.new_delete_res;<br>
+ static mutex res_lock;<br>
+ if (set) {<br>
+ new_res = new_res ? new_res : new_delete_resource();<br>
+ lock_guard<mutex> guard(res_lock);<br>
+ memory_resource * old_res = res;<br>
+ res = new_res;<br>
+ return old_res;<br>
+ } else {<br>
+ lock_guard<mutex> guard(res_lock);<br>
+ return res;<br>
+ }<br>
+#endif<br>
+}<br>
+<br>
+memory_resource * get_default_resource() _NOEXCEPT<br>
+{<br>
+ return __default_memory_resource();<br>
+}<br>
+<br>
+memory_resource * set_default_resource(memory_resource * __new_res) _NOEXCEPT<br>
+{<br>
+ return __default_memory_resource(true, __new_res);<br>
+}<br>
+<br>
+_LIBCPP_END_NAMESPACE_LFTS_PMR<br>
\ No newline at end of file<br>
<br>
Removed: libcxx/trunk/src/experimental/placeholder.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/placeholder.cpp?rev=268828&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/placeholder.cpp?rev=268828&view=auto</a><br>
==============================================================================<br>
--- libcxx/trunk/src/experimental/placeholder.cpp (original)<br>
+++ libcxx/trunk/src/experimental/placeholder.cpp (removed)<br>
@@ -1,14 +0,0 @@<br>
-//===--------------------------- TODO.cpp ---------------------------------===//<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>
-//===----------------------------------------------------------------------===//<br>
-<br>
-#include "experimental/__config"<br>
-<br>
-_LIBCPP_BEGIN_NAMESPACE_LFTS<br>
-<br>
-_LIBCPP_END_NAMESPACE_LFTS<br>
<br>
Added: libcxx/trunk/test/libcxx/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/construct_piecewise_pair.pass.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/construct_piecewise_pair.pass.cpp?rev=268829&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/construct_piecewise_pair.pass.cpp?rev=268829&view=auto</a><br>
==============================================================================<br>
--- libcxx/trunk/test/libcxx/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/construct_piecewise_pair.pass.cpp (added)<br>
+++ libcxx/trunk/test/libcxx/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/construct_piecewise_pair.pass.cpp Fri May 6 20:04:55 2016<br>
@@ -0,0 +1,178 @@<br>
+//===----------------------------------------------------------------------===//<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>
+//===----------------------------------------------------------------------===//<br>
+<br>
+// UNSUPPORTED: c++98, c++03<br>
+<br>
+// <experimental/memory_resource><br>
+<br>
+// template <class T> class polymorphic_allocator<br>
+<br>
+// template <class U1, class U2, class ...Args1, class ...Args2><br>
+// void polymorphic_allocator<T>::construct(pair<T1, T2>*, piecewise_construct_t<br>
+// tuple<Args1...> x, tuple<Args2...>)<br>
+<br>
+// The stardard specifiers a tranformation to uses-allocator construction as<br>
+// follows:<br>
+// - If uses_allocator_v<T1,memory_resource*> is false and<br>
+// is_constructible_v<T,Args1...> is true, then xprime is x.<br>
+// - Otherwise, if uses_allocator_v<T1,memory_resource*> is true and<br>
+// is_constructible_v<T1,allocator_arg_t,memory_resource*,Args1...> is true,<br>
+// then xprime is<br>
+// tuple_cat(make_tuple(allocator_arg, this->resource()), std::move(x)).<br>
+// - Otherwise, if uses_allocator_v<T1,memory_resource*> is true and<br>
+// is_constructible_v<T1,Args1...,memory_resource*> is true, then xprime is<br>
+// tuple_cat(std::move(x), make_tuple(this->resource())).<br>
+// - Otherwise the program is ill formed.<br>
+//<br>
+// The use of "xprime = tuple_cat(..., std::move(x), ...)" causes all of the<br>
+// objects in 'x' to be copied into 'xprime'. If 'x' contains any types which<br>
+// are stored by value this causes an unessary copy to occur. To prevent this<br>
+// libc++ changes this call into<br>
+// "xprime = forward_as_tuple(..., std::get<Idx>(std::move(x))..., ...)".<br>
+// 'xprime' contains references to the values in 'x' instead of copying them.<br>
+<br>
+// This test checks the number of copies incurred to the elements in<br>
+// 'tuple<Args1...>' and 'tuple<Args2...>'.<br>
+<br>
+#include <experimental/memory_resource><br>
+#include <type_traits><br>
+#include <utility><br>
+#include <tuple><br>
+#include <cassert><br>
+#include <cstdlib><br>
+#include "test_memory_resource.hpp"<br>
+<br>
+namespace ex = std::experimental::pmr;<br>
+<br>
+template <class T><br>
+struct TestHarness {<br>
+ TestResource R;<br>
+ ex::memory_resource * M = &R;<br>
+ ex::polymorphic_allocator<T> A = M;<br>
+ bool constructed = false;<br>
+ T * ptr;<br>
+<br>
+ TestHarness() : ptr(A.allocate(1)) {}<br>
+<br>
+ template <class ...Args><br>
+ void construct(Args&&... args) {<br>
+ A.construct(ptr, std::forward<Args>(args)...);<br>
+ constructed = true;<br>
+ }<br>
+<br>
+ ~TestHarness() {<br>
+ if (constructed) A.destroy(ptr);<br>
+ A.deallocate(ptr, 1);<br>
+ }<br>
+};<br>
+<br>
+struct CountCopies {<br>
+ int count;<br>
+ CountCopies() : count(0) {}<br>
+ CountCopies(CountCopies const& o) : count(o.count + 1) {}<br>
+};<br>
+<br>
+struct CountCopiesAllocV1 {<br>
+ typedef ex::memory_resource* allocator_type;<br>
+ allocator_type alloc;<br>
+ int count;<br>
+ CountCopiesAllocV1() : alloc(nullptr), count(0) {}<br>
+ CountCopiesAllocV1(std::allocator_arg_t, allocator_type const& a,<br>
+ CountCopiesAllocV1 const& o) : alloc(a), count(o.count + 1)<br>
+ {}<br>
+<br>
+ CountCopiesAllocV1(CountCopiesAllocV1 const& o) : count(o.count + 1) {}<br>
+};<br>
+<br>
+<br>
+struct CountCopiesAllocV2 {<br>
+ typedef ex::memory_resource* allocator_type;<br>
+ allocator_type alloc;<br>
+ int count;<br>
+ CountCopiesAllocV2() : alloc(nullptr), count(0) {}<br>
+ CountCopiesAllocV2(CountCopiesAllocV2 const& o, allocator_type const& a)<br>
+ : alloc(a), count(o.count + 1)<br>
+ { }<br>
+<br>
+ CountCopiesAllocV2(CountCopiesAllocV2 const& o) : count(o.count + 1) {}<br>
+};<br>
+<br>
+<br>
+int main()<br>
+{<br>
+ using PMR = ex::memory_resource*;<br>
+ using PMA = ex::polymorphic_allocator<char>;<br>
+<br>
+ {<br>
+ using T = CountCopies;<br>
+ using U = CountCopiesAllocV1;<br>
+ using P = std::pair<T, U>;<br>
+ using TH = TestHarness<P>;<br>
+<br>
+ std::tuple<T> t1;<br>
+ std::tuple<U> t2;<br>
+<br>
+ TestHarness<P> h;<br>
+ h.construct(std::piecewise_construct, t1, t2);<br>
+ P const& p = *h.ptr;<br>
+ assert(p.first.count == 2);<br>
+ assert(p.second.count == 2);<br>
+ assert(p.second.alloc == h.M);<br>
+ }<br>
+ {<br>
+ using T = CountCopiesAllocV1;<br>
+ using U = CountCopiesAllocV2;<br>
+ using P = std::pair<T, U>;<br>
+ using TH = TestHarness<P>;<br>
+<br>
+ std::tuple<T> t1;<br>
+ std::tuple<U> t2;<br>
+<br>
+ TestHarness<P> h;<br>
+ h.construct(std::piecewise_construct, std::move(t1), std::move(t2));<br>
+ P const& p = *h.ptr;<br>
+ assert(p.first.count == 2);<br>
+ assert(p.first.alloc == h.M);<br>
+ assert(p.second.count == 2);<br>
+ assert(p.second.alloc == h.M);<br>
+ }<br>
+ {<br>
+ using T = CountCopiesAllocV2;<br>
+ using U = CountCopiesAllocV1;<br>
+ using P = std::pair<T, U>;<br>
+ using TH = TestHarness<P>;<br>
+<br>
+ std::tuple<T> t1;<br>
+ std::tuple<U> t2;<br>
+<br>
+ TestHarness<P> h;<br>
+ h.construct(std::piecewise_construct, std::move(t1), std::move(t2));<br>
+ P const& p = *h.ptr;<br>
+ assert(p.first.count == 2);<br>
+ assert(p.first.alloc == h.M);<br>
+ assert(p.second.count == 2);<br>
+ assert(p.second.alloc == h.M);<br>
+ }<br>
+ {<br>
+ using T = CountCopiesAllocV2;<br>
+ using U = CountCopies;<br>
+ using P = std::pair<T, U>;<br>
+ using TH = TestHarness<P>;<br>
+<br>
+ std::tuple<T> t1;<br>
+ std::tuple<U> t2;<br>
+<br>
+ TestHarness<P> h;<br>
+ h.construct(std::piecewise_construct, t1, t2);<br>
+ P const& p = *h.ptr;<br>
+ assert(p.first.count == 2);<br>
+ assert(p.first.alloc == h.M);<br>
+ assert(p.second.count == 2);<br>
+ }<br>
+}<br>
<br>
Added: libcxx/trunk/test/libcxx/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/db_deallocate.pass.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/db_deallocate.pass.cpp?rev=268829&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/db_deallocate.pass.cpp?rev=268829&view=auto</a><br>
==============================================================================<br>
--- libcxx/trunk/test/libcxx/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/db_deallocate.pass.cpp (added)<br>
+++ libcxx/trunk/test/libcxx/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/db_deallocate.pass.cpp Fri May 6 20:04:55 2016<br>
@@ -0,0 +1,42 @@<br>
+//===----------------------------------------------------------------------===//<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>
+//===----------------------------------------------------------------------===//<br>
+<br>
+// UNSUPPORTED: c++98, c++03<br>
+<br>
+// <experimental/memory_resource><br>
+<br>
+// template <class T> class polymorphic_allocator<br>
+<br>
+// T* polymorphic_allocator<T>::deallocate(T*, size_t size)<br>
+<br>
+int AssertCount = 0;<br>
+<br>
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : (void)::AssertCount++)<br>
+#define _LIBCPP_DEBUG 0<br>
+#include <experimental/memory_resource><br>
+#include <type_traits><br>
+#include <cassert><br>
+<br>
+#include "test_memory_resource.hpp"<br>
+<br>
+namespace ex = std::experimental::pmr;<br>
+<br>
+int main()<br>
+{<br>
+ using Alloc = ex::polymorphic_allocator<int>;<br>
+ using Traits = std::allocator_traits<Alloc>;<br>
+ NullResource R;<br>
+ Alloc a(&R);<br>
+ const std::size_t maxSize = Traits::max_size(a);<br>
+<br>
+ a.deallocate(nullptr, maxSize);<br>
+ assert(AssertCount == 0);<br>
+ a.deallocate(nullptr, maxSize + 1);<br>
+ assert(AssertCount == 1);<br>
+}<br>
<br>
Added: libcxx/trunk/test/libcxx/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/max_size.pass.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/max_size.pass.cpp?rev=268829&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/max_size.pass.cpp?rev=268829&view=auto</a><br>
==============================================================================<br>
--- libcxx/trunk/test/libcxx/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/max_size.pass.cpp (added)<br>
+++ libcxx/trunk/test/libcxx/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/max_size.pass.cpp Fri May 6 20:04:55 2016<br>
@@ -0,0 +1,64 @@<br>
+//===----------------------------------------------------------------------===//<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>
+//===----------------------------------------------------------------------===//<br>
+<br>
+// UNSUPPORTED: c++98, c++03<br>
+<br>
+// <experimental/memory_resource><br>
+<br>
+// template <class T> class polymorphic_allocator<br>
+<br>
+// EXTENSION<br>
+// std::size_t polymorphic_allocator<T>::max_size() const noexcept<br>
+<br>
+#include <experimental/memory_resource><br>
+#include <type_traits><br>
+#include <cassert><br>
+<br>
+#include "test_memory_resource.hpp"<br>
+<br>
+namespace ex = std::experimental::pmr;<br>
+<br>
+template <std::size_t S><br>
+std::size_t getMaxSize() {<br>
+ using T = typename std::aligned_storage<S>::type;<br>
+ static_assert(sizeof(T) == S, "Required for test");<br>
+ return ex::polymorphic_allocator<T>{}.max_size();<br>
+}<br>
+<br>
+template <std::size_t S, std::size_t A><br>
+std::size_t getMaxSize() {<br>
+ using T = typename std::aligned_storage<S, A>::type;<br>
+ static_assert(sizeof(T) == S, "Required for test");<br>
+ return ex::polymorphic_allocator<T>{}.max_size();<br>
+}<br>
+<br>
+int main()<br>
+{<br>
+ {<br>
+ using Alloc = ex::polymorphic_allocator<int>;<br>
+ using Traits = std::allocator_traits<Alloc>;<br>
+ const Alloc a;<br>
+ static_assert(std::is_same<decltype(a.max_size()), Traits::size_type>::value, "");<br>
+ static_assert(noexcept(a.max_size()), "");<br>
+ }<br>
+ {<br>
+ constexpr std::size_t Max = std::numeric_limits<std::size_t>::max();<br>
+ assert(getMaxSize<1>() == Max);<br>
+ assert(getMaxSize<2>() == Max / 2);<br>
+ assert(getMaxSize<4>() == Max / 4);<br>
+ assert(getMaxSize<8>() == Max / 8);<br>
+ assert(getMaxSize<16>() == Max / 16);<br>
+ assert(getMaxSize<32>() == Max / 32);<br>
+ assert(getMaxSize<64>() == Max / 64);<br>
+ assert(getMaxSize<1024>() == Max / 1024);<br>
+<br>
+ assert((getMaxSize<6, 2>() == Max / 6));<br>
+ assert((getMaxSize<12, 4>() == Max / 12));<br>
+ }<br>
+}<br>
<br>
Added: libcxx/trunk/test/libcxx/experimental/memory/memory.resource.adaptor/memory.resource.adaptor.mem/db_deallocate.pass.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/experimental/memory/memory.resource.adaptor/memory.resource.adaptor.mem/db_deallocate.pass.cpp?rev=268829&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/experimental/memory/memory.resource.adaptor/memory.resource.adaptor.mem/db_deallocate.pass.cpp?rev=268829&view=auto</a><br>
==============================================================================<br>
--- libcxx/trunk/test/libcxx/experimental/memory/memory.resource.adaptor/memory.resource.adaptor.mem/db_deallocate.pass.cpp (added)<br>
+++ libcxx/trunk/test/libcxx/experimental/memory/memory.resource.adaptor/memory.resource.adaptor.mem/db_deallocate.pass.cpp Fri May 6 20:04:55 2016<br>
@@ -0,0 +1,45 @@<br>
+//===----------------------------------------------------------------------===//<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>
+//===----------------------------------------------------------------------===//<br>
+<br>
+// UNSUPPORTED: c++98, c++03<br>
+<br>
+// <experimental/memory_resource><br>
+<br>
+// template <class T> class polymorphic_allocator<br>
+<br>
+// T* polymorphic_allocator<T>::deallocate(T*, size_t size)<br>
+<br>
+int AssertCount = 0;<br>
+<br>
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : (void)::AssertCount++)<br>
+#define _LIBCPP_DEBUG 0<br>
+#include <experimental/memory_resource><br>
+#include <type_traits><br>
+#include <cassert><br>
+<br>
+#include "test_memory_resource.hpp"<br>
+<br>
+namespace ex = std::experimental::pmr;<br>
+<br>
+int main()<br>
+{<br>
+ using Alloc = NullAllocator<char>;<br>
+ using R = ex::resource_adaptor<Alloc>;<br>
+ AllocController P;<br>
+ ex::resource_adaptor<Alloc> r(Alloc{P});<br>
+ ex::memory_resource & m1 = r;<br>
+<br>
+ std::size_t maxSize = std::numeric_limits<std::size_t>::max()<br>
+ - alignof(std::max_align_t);<br>
+<br>
+ m1.deallocate(nullptr, maxSize);<br>
+ assert(AssertCount == 0);<br>
+ m1.deallocate(nullptr, maxSize + 1);<br>
+ assert(AssertCount >= 1);<br>
+}<br>
<br>
Added: libcxx/trunk/test/libcxx/experimental/memory/memory.resource.global/global_memory_resource_lifetime.pass.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/experimental/memory/memory.resource.global/global_memory_resource_lifetime.pass.cpp?rev=268829&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/experimental/memory/memory.resource.global/global_memory_resource_lifetime.pass.cpp?rev=268829&view=auto</a><br>
==============================================================================<br>
--- libcxx/trunk/test/libcxx/experimental/memory/memory.resource.global/global_memory_resource_lifetime.pass.cpp (added)<br>
+++ libcxx/trunk/test/libcxx/experimental/memory/memory.resource.global/global_memory_resource_lifetime.pass.cpp Fri May 6 20:04:55 2016<br>
@@ -0,0 +1,60 @@<br>
+//===----------------------------------------------------------------------===//<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>
+//===----------------------------------------------------------------------===//<br>
+<br>
+// UNSUPPORTED: c++98, c++03<br>
+<br>
+// <experimental/memory_resource><br>
+<br>
+// memory_resource * new_delete_resource()<br>
+<br>
+// The lifetime of the value returned by 'new_delete_resource()' should<br>
+// never end, even very late into program termination. This test constructs<br>
+// attempts to use 'new_delete_resource()' very late in program termination<br>
+// to detect lifetime issues.<br>
+<br>
+#include <experimental/memory_resource><br>
+#include <type_traits><br>
+#include <cassert><br>
+<br>
+namespace ex = std::experimental::pmr;<br>
+<br>
+struct POSType {<br>
+ ex::memory_resource* res = nullptr;<br>
+ void* ptr = nullptr;<br>
+ int n = 0;<br>
+ POSType() {}<br>
+ POSType(ex::memory_resource* r, void* p, int s) : res(r), ptr(p), n(s) {}<br>
+ ~POSType() {<br>
+ if (ptr) {<br>
+ if (!res) res = ex::get_default_resource();<br>
+ res->deallocate(ptr, n);<br>
+ }<br>
+ }<br>
+};<br>
+<br>
+void swap(POSType & L, POSType & R) {<br>
+ std::swap(L.res, R.res);<br>
+ std::swap(L.ptr, R.ptr);<br>
+ std::swap(L.n, R.n);<br>
+}<br>
+<br>
+POSType constructed_before_resources;<br>
+POSType constructed_before_resources2;<br>
+<br>
+// Constructs resources<br>
+ex::memory_resource* resource = ex::get_default_resource();<br>
+<br>
+POSType constructed_after_resources(resource, resource->allocate(1024), 1024);<br>
+POSType constructed_after_resources2(nullptr, resource->allocate(1024), 1024);<br>
+<br>
+int main()<br>
+{<br>
+ swap(constructed_after_resources, constructed_before_resources);<br>
+ swap(constructed_before_resources2, constructed_after_resources2);<br>
+}<br>
<br>
Added: libcxx/trunk/test/libcxx/experimental/memory/memory.resource.global/new_delete_resource_lifetime.pass.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/experimental/memory/memory.resource.global/new_delete_resource_lifetime.pass.cpp?rev=268829&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/experimental/memory/memory.resource.global/new_delete_resource_lifetime.pass.cpp?rev=268829&view=auto</a><br>
==============================================================================<br>
--- libcxx/trunk/test/libcxx/experimental/memory/memory.resource.global/new_delete_resource_lifetime.pass.cpp (added)<br>
+++ libcxx/trunk/test/libcxx/experimental/memory/memory.resource.global/new_delete_resource_lifetime.pass.cpp Fri May 6 20:04:55 2016<br>
@@ -0,0 +1,52 @@<br>
+//===----------------------------------------------------------------------===//<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>
+//===----------------------------------------------------------------------===//<br>
+<br>
+// UNSUPPORTED: c++98, c++03<br>
+<br>
+// <experimental/memory_resource><br>
+<br>
+// memory_resource * new_delete_resource()<br>
+<br>
+// The lifetime of the value returned by 'new_delete_resource()' should<br>
+// never end, even very late into program termination. This test constructs<br>
+// attempts to use 'new_delete_resource()' very late in program termination<br>
+// to detect lifetime issues.<br>
+<br>
+#include <experimental/memory_resource><br>
+#include <type_traits><br>
+#include <cassert><br>
+<br>
+namespace ex = std::experimental::pmr;<br>
+<br>
+struct POSType {<br>
+ ex::memory_resource* res = nullptr;<br>
+ void* ptr = nullptr;<br>
+ int n = 0;<br>
+ POSType() {res = ex::new_delete_resource(); ptr = res->allocate(42); n = 42; }<br>
+ POSType(ex::memory_resource* r, void* p, int s) : res(r), ptr(p), n(s) {}<br>
+ ~POSType() { if (ptr) res->deallocate(ptr, n); }<br>
+};<br>
+<br>
+void swap(POSType & L, POSType & R) {<br>
+ std::swap(L.res, R.res);<br>
+ std::swap(L.ptr, R.ptr);<br>
+ std::swap(L.n, R.n);<br>
+}<br>
+<br>
+POSType constructed_before_resources;<br>
+<br>
+// Constructs resources<br>
+ex::memory_resource* resource = ex::new_delete_resource();<br>
+<br>
+POSType constructed_after_resources(resource, resource->allocate(1024), 1024);<br>
+<br>
+int main()<br>
+{<br>
+ swap(constructed_after_resources, constructed_before_resources);<br>
+}<br>
<br>
Added: libcxx/trunk/test/libcxx/experimental/memory/memory.resource.synop/version.pass.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/experimental/memory/memory.resource.synop/version.pass.cpp?rev=268829&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/experimental/memory/memory.resource.synop/version.pass.cpp?rev=268829&view=auto</a><br>
==============================================================================<br>
--- libcxx/trunk/test/libcxx/experimental/memory/memory.resource.synop/version.pass.cpp (added)<br>
+++ libcxx/trunk/test/libcxx/experimental/memory/memory.resource.synop/version.pass.cpp Fri May 6 20:04:55 2016<br>
@@ -0,0 +1,22 @@<br>
+//===----------------------------------------------------------------------===//<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>
+//===----------------------------------------------------------------------===//<br>
+<br>
+// UNSUPPORTED: c++98, c++03<br>
+<br>
+// <experimental/memory_resource><br>
+<br>
+#include <experimental/memory_resource><br>
+<br>
+#ifndef _LIBCPP_VERSION<br>
+#error _LIBCPP_VERSION not defined<br>
+#endif<br>
+<br>
+int main()<br>
+{<br>
+}<br>
<br>
Added: libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.ctor/assign.pass.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.ctor/assign.pass.cpp?rev=268829&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.ctor/assign.pass.cpp?rev=268829&view=auto</a><br>
==============================================================================<br>
--- libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.ctor/assign.pass.cpp (added)<br>
+++ libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.ctor/assign.pass.cpp Fri May 6 20:04:55 2016<br>
@@ -0,0 +1,29 @@<br>
+//===----------------------------------------------------------------------===//<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>
+//===----------------------------------------------------------------------===//<br>
+<br>
+// UNSUPPORTED: c++98, c++03<br>
+<br>
+// <experimental/memory_resource><br>
+<br>
+// template <class T> class polymorphic_allocator<br>
+<br>
+// polymorphic_allocator operator=(polymorphic_allocator const &) = delete<br>
+<br>
+#include <experimental/memory_resource><br>
+#include <type_traits><br>
+#include <cassert><br>
+<br>
+namespace ex = std::experimental::pmr;<br>
+<br>
+int main()<br>
+{<br>
+ typedef ex::polymorphic_allocator<void> T;<br>
+ static_assert(std::is_copy_assignable<T>::value, "");<br>
+ static_assert(std::is_move_assignable<T>::value, "");<br>
+}<br>
<br>
Added: libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.ctor/copy.pass.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.ctor/copy.pass.cpp?rev=268829&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.ctor/copy.pass.cpp?rev=268829&view=auto</a><br>
==============================================================================<br>
--- libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.ctor/copy.pass.cpp (added)<br>
+++ libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.ctor/copy.pass.cpp Fri May 6 20:04:55 2016<br>
@@ -0,0 +1,48 @@<br>
+//===----------------------------------------------------------------------===//<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>
+//===----------------------------------------------------------------------===//<br>
+<br>
+// UNSUPPORTED: c++98, c++03<br>
+<br>
+// <experimental/memory_resource><br>
+<br>
+// template <class T> class polymorphic_allocator<br>
+<br>
+// polymorphic_allocator<T>::polymorphic_allocator(polymorphic_allocator const &);<br>
+<br>
+#include <experimental/memory_resource><br>
+#include <type_traits><br>
+#include <cassert><br>
+<br>
+namespace ex = std::experimental::pmr;<br>
+<br>
+int main()<br>
+{<br>
+ typedef ex::polymorphic_allocator<void> A1;<br>
+ {<br>
+ static_assert(<br>
+ std::is_copy_constructible<A1>::value, ""<br>
+ );<br>
+ static_assert(<br>
+ std::is_move_constructible<A1>::value, ""<br>
+ );<br>
+ }<br>
+ // copy<br>
+ {<br>
+ A1 const a((ex::memory_resource*)42);<br>
+ A1 const a2(a);<br>
+ assert(a.resource() == a2.resource());<br>
+ }<br>
+ // move<br>
+ {<br>
+ A1 a((ex::memory_resource*)42);<br>
+ A1 a2(std::move(a));<br>
+ assert(a.resource() == a2.resource());<br>
+ assert(a2.resource() == (ex::memory_resource*)42);<br>
+ }<br>
+}<br>
<br>
Added: libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.ctor/default.pass.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.ctor/default.pass.cpp?rev=268829&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.ctor/default.pass.cpp?rev=268829&view=auto</a><br>
==============================================================================<br>
--- libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.ctor/default.pass.cpp (added)<br>
+++ libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.ctor/default.pass.cpp Fri May 6 20:04:55 2016<br>
@@ -0,0 +1,48 @@<br>
+//===----------------------------------------------------------------------===//<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>
+//===----------------------------------------------------------------------===//<br>
+<br>
+// UNSUPPORTED: c++98, c++03<br>
+<br>
+// <experimental/memory_resource><br>
+<br>
+// template <class T> class polymorphic_allocator<br>
+<br>
+// polymorphic_allocator<T>::polymorphic_allocator() noexcept<br>
+<br>
+#include <experimental/memory_resource><br>
+#include <type_traits><br>
+#include <cassert><br>
+<br>
+#include "test_memory_resource.hpp"<br>
+<br>
+namespace ex = std::experimental::pmr;<br>
+<br>
+int main()<br>
+{<br>
+ {<br>
+ static_assert(<br>
+ std::is_nothrow_default_constructible<ex::polymorphic_allocator<void>>::value<br>
+ , "Must me nothrow default constructible"<br>
+ );<br>
+ }<br>
+ {<br>
+ // test that the allocator gets its resource from get_default_resource<br>
+ TestResource R1(42);<br>
+ ex::set_default_resource(&R1);<br>
+<br>
+ typedef ex::polymorphic_allocator<void> A;<br>
+ A const a;<br>
+ assert(a.resource() == &R1);<br>
+<br>
+ ex::set_default_resource(nullptr);<br>
+ A const a2;<br>
+ assert(a.resource() == &R1);<br>
+ assert(a2.resource() == ex::new_delete_resource());<br>
+ }<br>
+}<br>
<br>
Added: libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.ctor/memory_resource_convert.pass.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.ctor/memory_resource_convert.pass.cpp?rev=268829&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.ctor/memory_resource_convert.pass.cpp?rev=268829&view=auto</a><br>
==============================================================================<br>
--- libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.ctor/memory_resource_convert.pass.cpp (added)<br>
+++ libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.ctor/memory_resource_convert.pass.cpp Fri May 6 20:04:55 2016<br>
@@ -0,0 +1,45 @@<br>
+//===----------------------------------------------------------------------===//<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>
+//===----------------------------------------------------------------------===//<br>
+<br>
+// UNSUPPORTED: c++98, c++03<br>
+<br>
+// <experimental/memory_resource><br>
+<br>
+// template <class T> class polymorphic_allocator<br>
+<br>
+// polymorphic_allocator<T>::polymorphic_allocator(memory_resource *)<br>
+<br>
+#include <experimental/memory_resource><br>
+#include <type_traits><br>
+#include <cassert><br>
+<br>
+#include "test_memory_resource.hpp"<br>
+<br>
+namespace ex = std::experimental::pmr;<br>
+<br>
+int main()<br>
+{<br>
+ {<br>
+ typedef ex::polymorphic_allocator<void> A;<br>
+ static_assert(<br>
+ std::is_convertible<decltype(nullptr), A>::value<br>
+ , "Must be convertible"<br>
+ );<br>
+ static_assert(<br>
+ std::is_convertible<ex::memory_resource *, A>::value<br>
+ , "Must be convertible"<br>
+ );<br>
+ }<br>
+ {<br>
+ typedef ex::polymorphic_allocator<void> A;<br>
+ TestResource R;<br>
+ A const a(&R);<br>
+ assert(a.resource() == &R);<br>
+ }<br>
+}<br>
<br>
Added: libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.ctor/other_alloc.pass.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.ctor/other_alloc.pass.cpp?rev=268829&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.ctor/other_alloc.pass.cpp?rev=268829&view=auto</a><br>
==============================================================================<br>
--- libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.ctor/other_alloc.pass.cpp (added)<br>
+++ libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.ctor/other_alloc.pass.cpp Fri May 6 20:04:55 2016<br>
@@ -0,0 +1,57 @@<br>
+//===----------------------------------------------------------------------===//<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>
+//===----------------------------------------------------------------------===//<br>
+<br>
+// UNSUPPORTED: c++98, c++03<br>
+<br>
+// <experimental/memory_resource><br>
+<br>
+// template <class T> class polymorphic_allocator<br>
+<br>
+// template <class U><br>
+// polymorphic_allocator<T>::polymorphic_allocator(polymorphic_allocator<U> const &);<br>
+<br>
+<br>
+#include <experimental/memory_resource><br>
+#include <type_traits><br>
+#include <cassert><br>
+<br>
+namespace ex = std::experimental::pmr;<br>
+<br>
+int main()<br>
+{<br>
+ typedef ex::polymorphic_allocator<void> A1;<br>
+ typedef ex::polymorphic_allocator<char> A2;<br>
+ { // Test that the conversion is implicit and noexcept.<br>
+ static_assert(<br>
+ std::is_convertible<A1 const &, A2>::value, ""<br>
+ );<br>
+ static_assert(<br>
+ std::is_convertible<A2 const &, A1>::value, ""<br>
+ );<br>
+ static_assert(<br>
+ std::is_nothrow_constructible<A1, A2 const &>::value, ""<br>
+ );<br>
+ static_assert(<br>
+ std::is_nothrow_constructible<A2, A1 const &>::value, ""<br>
+ );<br>
+ }<br>
+ // copy other type<br>
+ {<br>
+ A1 const a((ex::memory_resource*)42);<br>
+ A2 const a2(a);<br>
+ assert(a.resource() == a2.resource());<br>
+ assert(a2.resource() == (ex::memory_resource*)42);<br>
+ }<br>
+ {<br>
+ A1 a((ex::memory_resource*)42);<br>
+ A2 const a2(std::move(a));<br>
+ assert(a.resource() == a2.resource());<br>
+ assert(a2.resource() == (ex::memory_resource*)42);<br>
+ }<br>
+}<br>
<br>
Added: libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.eq/equal.pass.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.eq/equal.pass.cpp?rev=268829&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.eq/equal.pass.cpp?rev=268829&view=auto</a><br>
==============================================================================<br>
--- libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.eq/equal.pass.cpp (added)<br>
+++ libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.eq/equal.pass.cpp Fri May 6 20:04:55 2016<br>
@@ -0,0 +1,133 @@<br>
+//===----------------------------------------------------------------------===//<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>
+//===----------------------------------------------------------------------===//<br>
+<br>
+// UNSUPPORTED: c++98, c++03<br>
+<br>
+// <experimental/memory_resource><br>
+<br>
+// template <class T> class polymorphic_allocator;<br>
+<br>
+// template <class T, class U><br>
+// bool operator==(<br>
+// polymorphic_allocator<T> const &<br>
+// , polymorphic_allocator<U> const &) noexcept<br>
+<br>
+#include <experimental/memory_resource><br>
+#include <type_traits><br>
+#include <cassert><br>
+<br>
+#include "test_memory_resource.hpp"<br>
+<br>
+namespace ex = std::experimental::pmr;<br>
+<br>
+int main()<br>
+{<br>
+ typedef ex::polymorphic_allocator<void> A1;<br>
+ typedef ex::polymorphic_allocator<int> A2;<br>
+ // check return types<br>
+ {<br>
+ A1 const a1;<br>
+ A2 const a2;<br>
+ static_assert(std::is_same<decltype(a1 == a2), bool>::value, "");<br>
+ static_assert(noexcept(a1 == a2), "");<br>
+ }<br>
+ // equal same type (different resource)<br>
+ {<br>
+ TestResource d1(1);<br>
+ TestResource d2(1);<br>
+ A1 const a1(&d1);<br>
+ A1 const a2(&d2);<br>
+<br>
+ assert(a1 == a2);<br>
+ assert(d1.checkIsEqualCalledEq(1));<br>
+ assert(d2.checkIsEqualCalledEq(0));<br>
+<br>
+ d1.reset();<br>
+<br>
+ assert(a2 == a1);<br>
+ assert(d1.checkIsEqualCalledEq(0));<br>
+ assert(d2.checkIsEqualCalledEq(1));<br>
+ }<br>
+ // equal same type (same resource)<br>
+ {<br>
+ TestResource d1;<br>
+ A1 const a1(&d1);<br>
+ A1 const a2(&d1);<br>
+<br>
+ assert(a1 == a2);<br>
+ assert(d1.checkIsEqualCalledEq(0));<br>
+<br>
+ assert(a2 == a1);<br>
+ assert(d1.checkIsEqualCalledEq(0));<br>
+ }<br>
+ // equal different type (different resource)<br>
+ {<br>
+ TestResource d1(42);<br>
+ TestResource d2(42);<br>
+ A1 const a1(&d1);<br>
+ A2 const a2(&d2);<br>
+<br>
+ assert(a1 == a2);<br>
+ assert(d1.checkIsEqualCalledEq(1));<br>
+ assert(d2.checkIsEqualCalledEq(0));<br>
+<br>
+ assert(a2 == a1);<br>
+ assert(d1.checkIsEqualCalledEq(1));<br>
+ assert(d2.checkIsEqualCalledEq(1));<br>
+<br>
+ }<br>
+ // equal different type (same resource)<br>
+ {<br>
+ TestResource d1(42);<br>
+ A1 const a1(&d1);<br>
+ A2 const a2(&d1);<br>
+<br>
+ assert(a1 == a2);<br>
+ assert(d1.checkIsEqualCalledEq(0));<br>
+<br>
+ assert(a2 == a1);<br>
+ assert(d1.checkIsEqualCalledEq(0));<br>
+<br>
+ }<br>
+ // not equal same type<br>
+ {<br>
+ TestResource d1(1);<br>
+ TestResource d2(2);<br>
+ A1 const a1(&d1);<br>
+ A1 const a2(&d2);<br>
+<br>
+ assert(!(a1 == a2));<br>
+ assert(d1.checkIsEqualCalledEq(1));<br>
+ assert(d2.checkIsEqualCalledEq(0));<br>
+<br>
+ d1.reset();<br>
+<br>
+ assert(!(a2 == a1));<br>
+ assert(d1.checkIsEqualCalledEq(0));<br>
+ assert(d2.checkIsEqualCalledEq(1));<br>
+<br>
+ }<br>
+ // not equal different types<br>
+ {<br>
+ TestResource d1;<br>
+ TestResource1 d2;<br>
+ A1 const a1(&d1);<br>
+ A2 const a2(&d2);<br>
+<br>
+ assert(!(a1 == a2));<br>
+ assert(d1.checkIsEqualCalledEq(1));<br>
+ assert(d2.checkIsEqualCalledEq(0));<br>
+<br>
+ d1.reset();<br>
+<br>
+ assert(!(a2 == a1));<br>
+ assert(d1.checkIsEqualCalledEq(0));<br>
+ assert(d2.checkIsEqualCalledEq(1));<br>
+ }<br>
+}<br>
<br>
Added: libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.eq/not_equal.pass.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.eq/not_equal.pass.cpp?rev=268829&view=auto" rel="noreferrer" target="_blank"></a></blockquote></div>
</div></div></blockquote></div><br></div>