On 03/15/2016 08:33 PM, Glen Fernandes wrote:
On Tue, Mar 15, 2016 at 7:02 PM, Phil Bouchard wrote:
Ok I fixed it and the code will look like the following:
One more thing: I suspect the following will not work, with a glance at your code: Change 'U' into:
struct W { explicit W(int) { } W(const W&) = delete; W(W&&) { } W& operator=(const W&) = delete; W& operator=(W&&) = delete; }; struct U { U(W&&) { } };
Now with shared_ptr and allocate_shared, this will compile just fine:
p1 = allocate_shared<U>(Allocator<U>(n1, m2), W(1));
With root_ptr, I'm guessing you would change it to something like:
allocator_type a1(n1, m1); p1 = new (a1) node(a1, W(1));
Your implementation looks like it will try to copy W which would fail to compile.
It fails to compile (I do not support move semantics yet): allocator.cpp:65:9: error: no matching function for call to ‘U::U(const W&)’ ::new(p) U(std::forward<Args>(args)...);