I'm trying the following:
std::unique_ptr<Response> response = std::make_unique<Response>(incomingData);
if (someCondition) {
analyzeResponse(std::move(response));
return;
}
...
analyzeResponse declaration:
void analyzeResponse(std::unique_ptr<Response> response);
Response class:
class Response
{
public:
Response();
explicit Response(string data);
...
private:
string data;
}
I know that std::unique_ptr can't be copied and I use std::move here. But in spite of this I get an error:
use of deleted function ‘std::unique_ptr<_Tp, _Dp>::unique_ptr(const std::unique_ptr<_Tp, _Dp>&) [with _Tp = Response; _Dp = std::default_delete<Response>]’
Spent much time, but I couldn't figure it out why that error occurred and didn't find anything helpful in the internet.
First of all my std::unique_ptr<Response> response is not const, why is it const in error message? I don't copy unique_ptr, I move it, right? And I don't have any std::unique_ptr in my Response class.
Please, somebody explain me what I understand wrong.
Aucun commentaire:
Enregistrer un commentaire