Здравствуйте!
MSVC2019, С++17
Есть базовый класс, конструктор копирования запрещён.
Есть реализация
struct WindowTimerImpl : public WindowTimerBase
{
//...
WindowTimerImpl(HWND h, UINT_PTR id, timeout_t timeoutMs) {}
static
WindowTimerImpl create(HWND h, UINT_PTR requestedId, timeout_t timeoutMs)
{
auto id = ::SetTimer(h, requestedId, timeoutMs, 0);
if (id==0)
{
throw std::runtime_error("Failed to create WindowTimer");
}
return WindowTimerImpl(h, id, timeoutMs, true);
// return std::move(WindowTimerImpl(h, id, timeoutMs, true)); // !!! move version
}
//...
};
В классе окна есть функция создания
virtual WindowTimer createTimer(timeout_t timeoutMs) const override
{
auto pSharedImpl = std::make_shared<WindowTimerImpl>(WindowTimerImpl::create(getHwnd(), curTimerId++, timeoutMs));
//...
Говорит, что "attempting to reference a deleted function"
Ошибка иницииируется в недрах std в _Construct_in_place при вызове forward:
| Скрытый текст |
| template <class _Ty, class... _Types>
_CONSTEXPR20_DYNALLOC void _Construct_in_place(_Ty& _Obj, _Types&&... _Args) noexcept(
is_nothrow_constructible_v<_Ty, _Types...>) {
#ifdef __cpp_lib_constexpr_dynamic_alloc
if (_STD is_constant_evaluated()) {
_STD construct_at(_STD addressof(_Obj), _STD forward<_Types>(_Args)...);
} else
#endif // __cpp_lib_constexpr_dynamic_alloc
{
::new (_Voidify_iter(_STD addressof(_Obj))) _Ty(_STD forward<_Types>(_Args)...); // !!!
}
}
|
| |
Ладно, попробовал вернуть через std::move. Стало ругаться на строчку с ним, но суть осталась та же.
Видимо, я чего-то не понимаю. Не подскажете, что?