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: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]
    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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to