<div dir="rtl"><div dir="ltr">A common pattern is having one allocator serve several data structures, 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 dir="ltr"><br></div><div dir="ltr">Yaron</div><div dir="ltr"><br></div></div>