New to c++ here, I'm not sure what to look up to solve this problem so I'm asking here.
I am trying to use the std::partition
function to partition a list. In doing so, I make a call somewhat like this:
typename std::vector<MyType>::iterator mid =
std::partition(begin, end, [xval](MyType p){return p.x <= xval;});
Where begin
and end
are the beginning and end iterators for the list of MyType
's that I want to reorder. However, when I do this, I get the following compilation error:
'MyType' has been explicitly marked deleted here
MyType(const MyType& src) = delete;
passing argument to parameter 'p' here
std::partition(begin, end, [xval](MyType p){return p.x <= xval;});
I've changed the type names around, but this is the long and short of it. I've done some looking around to figure out that because I made MyType
non-copyable, my code is complaining because I am apparently copying it into the lambda function for partition when I write "MyType p
" in those parenthesis.
My question is: How can I partition this list while not copying the arguments? I would really rather it be this list than any other (as in, I don't want to partition a list of indices if I can avoid it), because I want contiguous groups in this list to satisfy my predicate in order to make other parts of my code easier to write.
Edit: Definition of relevant part of MyType
class MyType {
public:
...
Object(const Object& src) = delete;
Object& operator=(const Object& src) = delete;
Object& operator=(Object&& src) = default;
Object(Object&& src) = default;
...
float x;
}
Aucun commentaire:
Enregistrer un commentaire