moya-lang / Allocator

Ultra fast C++11 allocator for STL containers.
BSD 2-Clause "Simplified" License
270 stars 25 forks source link

Move constructor and move assignment operator #19

Open ibogosavljevic opened 2 years ago

ibogosavljevic commented 2 years ago

I really miss move constructor and move assignment operator (they've been deleted). My code has something like this:

class my_class { Moya::MemoryPool poo; };

my_class create() { my_class m; ... return m; }

my_class x = create(); // This doesn't compile because move constructor is deleted.

Can you fix it?

ZigRazor commented 2 years ago

Same Problem with Google Test and Google Benchmark

moya-mmoczala commented 1 year ago

The move constructor and move assignment operator are deleted on purpose. It is not intended to use it in the way you presented. Instead, the class should be specified as a template parameter to std containers as described in the example on ReadMe.md (like: std::list<int, Allocator<int, 16 * 1024>> list3;). I leave this commend opened. Please let me know if there is a real need for doing it as you described so I can rethink the design. Thanks for commenting.