Я пытаюсь создать unique_ptr с настраиваемым средством удаления, затем инициализирую его и пытаюсь передать в структуру с той же подписью.
Код: Выделить всё
#pragma once
#include "common.hpp"
namespace framework {
using body_ptr = std::unique_ptr; // custom deleter
struct entityprops {
body_ptr body{nullptr, [](cpBody *) {}};
entityprops(const entityprops &) = delete;
entityprops &operator=(const entityprops &) = delete;
entityprops(entityprops &&) noexcept = default;
entityprops &operator=(entityprops &&) noexcept = default;
};
}
Код: Выделить всё
const auto body = body_ptr(cpBodyNew(1, 1), [](cpBody *body) { cpBodyFree(body); });
entityprops props{
std::move(body) // ERROR clang: Call to implicitly-deleted copy constructor of 'body_ptr' (aka 'unique_ptr')
};
Подробнее здесь: https://stackoverflow.com/questions/791 ... tructor-of
Мобильная версия