[libcxx] r296831 - remove max_size() extension from polymorphic_allocator. It is unneeded

Eric Fiselier via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 2 14:10:15 PST 2017


Author: ericwf
Date: Thu Mar  2 16:10:14 2017
New Revision: 296831

URL: http://llvm.org/viewvc/llvm-project?rev=296831&view=rev
Log:
remove max_size() extension from polymorphic_allocator. It is unneeded

Removed:
    libcxx/trunk/test/libcxx/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/max_size.pass.cpp
Modified:
    libcxx/trunk/include/experimental/memory_resource

Modified: libcxx/trunk/include/experimental/memory_resource
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/memory_resource?rev=296831&r1=296830&r2=296831&view=diff
==============================================================================
--- libcxx/trunk/include/experimental/memory_resource (original)
+++ libcxx/trunk/include/experimental/memory_resource Thu Mar  2 16:10:14 2017
@@ -181,7 +181,7 @@ public:
     // 8.6.3, memory.polymorphic.allocator.mem
     _LIBCPP_INLINE_VISIBILITY
     _ValueType* allocate(size_t __n) {
-        if (__n > max_size()) {
+        if (__n > __max_size()) {
             __throw_length_error(
                 "std::experimental::pmr::polymorphic_allocator<T>::allocate(size_t n)"
                 " 'n' exceeds maximum supported size");
@@ -193,7 +193,7 @@ public:
 
     _LIBCPP_INLINE_VISIBILITY
     void deallocate(_ValueType * __p, size_t __n) _NOEXCEPT {
-        _LIBCPP_ASSERT(__n <= max_size(),
+        _LIBCPP_ASSERT(__n <= __max_size(),
                        "deallocate called for size which exceeds max_size()");
         __res_->deallocate(__p, __n * sizeof(_ValueType), alignof(_ValueType));
     }
@@ -266,10 +266,6 @@ public:
         { __p->~_Tp(); }
 
     _LIBCPP_INLINE_VISIBILITY
-    size_t max_size() const _NOEXCEPT
-        { return numeric_limits<size_t>::max() / sizeof(value_type); }
-
-    _LIBCPP_INLINE_VISIBILITY
     polymorphic_allocator
     select_on_container_copy_construction() const _NOEXCEPT
         { return polymorphic_allocator(); }
@@ -309,6 +305,10 @@ private:
         return _Tup(_VSTD::get<_Idx>(_VSTD::move(__t))..., resource());
     }
 
+    _LIBCPP_INLINE_VISIBILITY
+    size_t __max_size() const _NOEXCEPT
+        { return numeric_limits<size_t>::max() / sizeof(value_type); }
+
     memory_resource * __res_;
 };
 

Removed: libcxx/trunk/test/libcxx/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/max_size.pass.cpp
URL: 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=296830&view=auto
==============================================================================
--- libcxx/trunk/test/libcxx/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/max_size.pass.cpp (original)
+++ libcxx/trunk/test/libcxx/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/max_size.pass.cpp (removed)
@@ -1,65 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// REQUIRES: c++experimental
-// UNSUPPORTED: c++98, c++03
-
-// <experimental/memory_resource>
-
-// template <class T> class polymorphic_allocator
-
-// EXTENSION
-// std::size_t polymorphic_allocator<T>::max_size() const noexcept
-
-#include <experimental/memory_resource>
-#include <type_traits>
-#include <cassert>
-
-#include "test_memory_resource.hpp"
-
-namespace ex = std::experimental::pmr;
-
-template <std::size_t S>
-std::size_t getMaxSize() {
-    using T = typename std::aligned_storage<S>::type;
-    static_assert(sizeof(T) == S, "Required for test");
-    return ex::polymorphic_allocator<T>{}.max_size();
-}
-
-template <std::size_t S, std::size_t A>
-std::size_t getMaxSize() {
-    using T = typename std::aligned_storage<S, A>::type;
-    static_assert(sizeof(T) == S, "Required for test");
-    return ex::polymorphic_allocator<T>{}.max_size();
-}
-
-int main()
-{
-    {
-        using Alloc = ex::polymorphic_allocator<int>;
-        using Traits = std::allocator_traits<Alloc>;
-        const Alloc a;
-        static_assert(std::is_same<decltype(a.max_size()), Traits::size_type>::value, "");
-        static_assert(noexcept(a.max_size()), "");
-    }
-    {
-        constexpr std::size_t Max = std::numeric_limits<std::size_t>::max();
-        assert(getMaxSize<1>()    == Max);
-        assert(getMaxSize<2>()    == Max / 2);
-        assert(getMaxSize<4>()    == Max / 4);
-        assert(getMaxSize<8>()    == Max / 8);
-        assert(getMaxSize<16>()   == Max / 16);
-        assert(getMaxSize<32>()   == Max / 32);
-        assert(getMaxSize<64>()   == Max / 64);
-        assert(getMaxSize<1024>() == Max / 1024);
-
-        assert((getMaxSize<6,  2>() == Max / 6));
-        assert((getMaxSize<12, 4>() == Max / 12));
-    }
-}




More information about the cfe-commits mailing list