Skip to content

Commit

Permalink
[libcxx] Resolve LWG 2724 protected -> private.
Browse files Browse the repository at this point in the history
Fixes LWG issue 2724: "The protected virtual member functions of memory_resource should be private."

Differential Revision: https://reviews.llvm.org/D66615
  • Loading branch information
zoecarver committed Nov 23, 2020
1 parent 03dab46 commit 0a20660
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
5 changes: 2 additions & 3 deletions libcxx/include/experimental/memory_resource
Expand Up @@ -116,7 +116,7 @@ public:
{ return do_is_equal(__other); }

// 8.5.3, memory.resource.priv
protected:
private:
virtual void* do_allocate(size_t, size_t) = 0;
virtual void do_deallocate(void*, size_t, size_t) = 0;
virtual bool do_is_equal(memory_resource const &) const _NOEXCEPT = 0;
Expand Down Expand Up @@ -381,7 +381,7 @@ public:
{ return __alloc_; }

// 8.7.3, memory.resource.adaptor.mem
protected:
private:
virtual void * do_allocate(size_t __bytes, size_t)
{
if (__bytes > __max_size()) {
Expand All @@ -407,7 +407,6 @@ protected:
return __p ? __alloc_ == __p->__alloc_ : false;
}

private:
_LIBCPP_INLINE_VISIBILITY
size_t __max_size() const _NOEXCEPT {
return numeric_limits<size_t>::max() - _MaxAlign;
Expand Down
Expand Up @@ -10,19 +10,19 @@

// <experimental/memory_resource>

// memory_resource::do_allocate(size_t, size_t); /* protected */
// memory_resource::do_deallocate(void*, size_t, size_t); /* protected */
// memory_resource::do_is_equal(memory_resource const&); /* protected */
// memory_resource::do_allocate(size_t, size_t); /* private */
// memory_resource::do_deallocate(void*, size_t, size_t); /* private */
// memory_resource::do_is_equal(memory_resource const&); /* private */

#include <experimental/memory_resource>

namespace ex = std::experimental::pmr;

int main(int, char**) {
ex::memory_resource *m = ex::new_delete_resource();
m->do_allocate(0, 0); // expected-error{{'do_allocate' is a protected member}}
m->do_deallocate(nullptr, 0, 0); // expected-error{{'do_deallocate' is a protected member}}
m->do_is_equal(*m); // expected-error{{'do_is_equal' is a protected member}}
m->do_allocate(0, 0); // expected-error{{'do_allocate' is a private member}}
m->do_deallocate(nullptr, 0, 0); // expected-error{{'do_deallocate' is a private member}}
m->do_is_equal(*m); // expected-error{{'do_is_equal' is a private member}}

return 0;
}

0 comments on commit 0a20660

Please sign in to comment.