When compiling my project with Visual Studio 2015 (64-bit, project configured for C++11) I discovered some
errors when working with UniquePtrs. I am using Urho3D 1.7.
Firstly, attempting to swap two UniquePtrs like so:
UniquePtr<Thing> thing;
thing.Reset(new Thing());
UniquePtr<Thing> thing2;
thing.Swap(thing2);
Produces this error:
'Urho3D::UniquePtr<Thing>::Swap': function does not take 2 arguments UrhoTest c:\users\andso\desktop\tools\urho3d-1.6-binaries\include\urho3d\Container\Ptr.h 598
(I know the folder says it’s version 1.6, but it’s 1.7. I did not wish to bother changing all of the environment variables just to rename it)
With “Thing” being a simple class defined like so:
class Thing
{
public:
int diddly = 0;
};
Secondly, I find that making a Urho3D::Vector of UniquePtrs does not work. I suspect this may be an intentional design tradeoff but I am unsure. My code looks like this:
UniquePtr<Thing> thing;
thing.Reset(new Thing());
...
Vector<UniquePtr<Thing>> things = Vector<UniquePtr<Thing>>();
things.Push(thing); //From my understanding, move semantics will transfer ownership from "thing" to the vector
And the following error is produced:
'Urho3D::UniquePtr<Thing>::operator =': cannot access private member declared in class 'Urho3D::UniquePtr<Thing>' UrhoTest c:\users\andso\desktop\tools\urho3d-1.6-binaries\include\urho3d\Container\Vector.h 526
I have isolated these two issues into their own Urho3D project that I have uploaded here.
(Because the project I’m working on is much too large)
These issues are not urgent; I merely felt that I should report the problem.