Earlier today I saw a question (see below) of really low quality, which only copy and pasted the whole code, without an MCVE and a clear pointer where exactly the error occurs. The English can be better, but it's not that bad in my opinion.
Should I try to edit the question to an MCVE? Or just leave it alone and move on?
I think that the question can be greatly improved to a good question, and I don't think this question has a dupe. I thought of editing it (see below).
My edit probably can be improved, but it's a lot better than the wall of code of the original question (I think). Note that the code (except for my error comment, and I removed the properties of Mesh
) is copy-pasted from the code the OP posted.
Is this appropriate? Should one edit questions without an MCVE to a question with an MVCE? Or should the OP do it?
Does my edit make sense (i.e. is the question a good question?)?
What should I do?
I removed the code/errors so that this question doesn't get too long:D
std::unique_ptr::unique_ptr(__gnu_cxx::__alloc_traits >::value_type&)’
i'm using C++ std11 and i've the following code
//38 lines of code ommited
with my class Model that contain an std::vector meshes;
when i compile this code i'm the following error:
//55 lines of long errors ommitted
please i don't understand where's the error, i've a vector of Mesh and use the operator[] the give me a Mesh and with this i creat an unique_ptr
Thanks.
PS. those are my class:
//52 lines of code ommitted
Error when trying to create a unique pointer to an object
I am trying to make a vector of unique pointers to Mesh
objects, but I am getting an error when I create the unique pointer to the object.
class Mesh {};
std::vector<std::unique_ptr<Mesh>> objects;
std::unique_ptr<Mesh> myMesh( myModel.meshes[0] ); //error: no matching function call
objects.push_back(std::move(myMesh));
meshes
is a std::vector<Mesh>
.
I can't seem to understand why it doesn't work because operator[]
returns a Mesh
, and I can use that Mesh
to initialize a std::unique_ptr
.
The full error is:
error: no matching function for call to ‘std::unique_ptr<Mesh>::unique_ptr(__gnu_cxx::__alloc_traits<std::allocator<Mesh> >::value_type&)’
std::unique_ptr<Mesh> myMesh( myModel.meshes[0] );
^
Why can't I create a unique pointer to a Mesh
object?