https://llvm.org/bugs/show_bug.cgi?id=24075

            Bug ID: 24075
           Summary: scoped_allocator_adaptor lacks the std::pair
                    construct() overloads!
           Product: libc++
           Version: 3.6
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]
    Classification: Unclassified

The overload that actually gets used is the std::uses_allocator -> false
overload, which just forwards all received arguments into the std::pair
constructor.  This will default construct all inner allocators for any
allocator aware containers inside of a std::pair instead of copy constructing
the allocators from the scoped_allocator_adaptor that gets passed to the outer
container.

For example ...

struct Alloc { STATE WHAT NEEDS COPYIN' };

using outer = Alloc<std::pair<char, std::vector<int, Alloc<int>>>>;
using inner = Alloc<int>;
using saa = std::scoped_allocator_adaptor<outer, inner>;

std::vector<
   std::pair<char, std::vector<int, Alloc<int>>>,
   saa
> vec(saa(outer(123), inner(432)));

vec.emplace_back(); // default constructs the allocator in the pair's
std::vector
                    // instead of copying from inner(432)

-- 
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