<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Nov 17, 2014 at 1:13 AM, Yaron Keren <span dir="ltr"><<a href="mailto:yaron.keren@gmail.com" target="_blank">yaron.keren@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="rtl"><div dir="ltr">A common pattern is having one allocator serve several data structures, </div></div></blockquote><div><br></div><div>Given that we don't have any uses or tests of this in tree (since it doesn't work in StringMap and I assume it doesn't work in any of our other ADTs either?) I suspect it's not quite as common as it may appear. I'm not sure it's even valid for C++ standard allocators (which LLVM's allocators are not implementations of), is it?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="rtl"><div dir="ltr">for instance</div><div dir="ltr"><br></div><div dir="ltr"><div> typedef StringMap<bool, BumpPtrAllocator&> SymbolTable;<br></div><div> BumpPtrAllocator Allocator;</div><div><div> SymbolTable Sym1;</div></div><div><div> SymbolTable Sym2;</div></div><div><div> Sym2 = std::move(Sym1);</div></div><div><br></div></div><div dir="ltr">With gcc 4.9.1 this fails <br></div><div dir="ltr"><br></div><div dir="ltr"><div dir="ltr">/llvm/include/llvm/ADT/StringMap.h:</div><div dir="ltr">  In instantiation of 'llvm::StringMap<ValueTy, AllocatorTy>::StringMap(llvm::StringMap<ValueTy, AllocatorTy>&&)</div><div dir="ltr">  [with ValueTy = llvm::MCSymbol*; AllocatorTy = llvm::BumpPtrAllocatorImpl<>&]':</div><div dir="ltr"><br></div><div dir="ltr">/llvm/include/llvm/ADT/StringMap.h:243:74: </div><div dir="ltr">  error: invalid initialization of non-const reference of type 'llvm::BumpPtrAllocatorImpl<>&' </div><div dir="ltr">  from an rvalue of type 'std::remove_reference<llvm::BumpPtrAllocatorImpl<>&>::type {aka llvm::BumpPtrAllocatorImpl<>}'</div><div dir="ltr">       : StringMapImpl(std::move(RHS)), Allocator(std::move(RHS.Allocator)) {}</div><div dir="ltr"><br></div><div>due to the inability to move the allocator reference where in fact we wish to copy it.</div></div><div dir="ltr"><br></div><div dir="ltr"><div dir="ltr">With Visual C++ 2013 the code compiles and apperantly copies the allocator reference.<br></div></div><div dir="ltr"><br></div><div dir="ltr">What is the proper way to move such StringMaps or other data structures using an allocator reference?</div></div></blockquote><div><br>I imagine the correct way to do this would be to write a wrapper/proxy allocator (with a raw Allocator* inside it that can then be correctly copied/moved/whatever). Though I could be wrong/haven't given this lots of thought.<br><br>- David<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="rtl"><span class="HOEnZb"><font color="#888888"><div dir="ltr"><br></div><div dir="ltr">Yaron</div><div dir="ltr"><br></div></font></span></div>
<br>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div></div>