[LLVMbugs] [Bug 20460] New: [C++11] allocate_shared should not require rebind of an allocator

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sat Jul 26 10:16:47 PDT 2014


http://llvm.org/bugs/show_bug.cgi?id=20460

            Bug ID: 20460
           Summary: [C++11] allocate_shared should not require rebind of
                    an allocator
           Product: libc++
           Version: unspecified
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: kariya_mitsuru at hotmail.com
                CC: llvmbugs at cs.uiuc.edu, mclow.lists at gmail.com
    Classification: Unclassified

The sample code below should be compiled successfully.

================================================================
#include <memory>

template <typename T>
struct Allocator {
  typedef T value_type;
  Allocator() = default;
  template <typename U>
  Allocator(const Allocator<U>&) {}
  T* allocate(size_t n) {
     return static_cast<T*>(::operator new(sizeof(T) * n));
  }
  void deallocate(T* p, size_t) {
    ::operator delete(static_cast<void*>(p));
  }
};

template <typename T, typename U>
bool operator==(const Allocator<T>&, const Allocator<U>&)
{
  return true;
}

template <typename T, typename U>
bool operator!=(const Allocator<T>&, const Allocator<U>&)
{
  return false;
}

int main()
{
  auto p = std::allocate_shared<int>(Allocator<int>());
}
================================================================

This sample is compiled successfully if the custom allocator Allocator has a
rebind template.

According to C++11 standard 17.6.3.5 Allocator requirements
[allocator.requirements], a rebind template is not required for a custom
allocator.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140726/4b013104/attachment.html>


More information about the llvm-bugs mailing list