No known conversion from ‘unique_ptr<Wt::WContainerWidget>’ to ‘unique_ptr<Wt::WWidget>’
Added by Harm about 4 years ago
Hello,
I'm trying to pass a WContainerWidget to a WPopupWidget, but my compiler doesn't like this.
auto containerPtr = std::make_unique<Wt::WContainerWidget>();
auto popupPtr = std::make_unique<Wt::WPopupWidget>(containerPtr);
I'm getting
/usr/include/c++/10.2.0/bits/unique_ptr.h:962:30: error: no matching function for call to 'Wt::WPopupWidget::WPopupWidget(std::unique_ptr<Wt::WContainerWidget>&)'
962 | { return unique_ptr<_Tp>(new _Tp(std::forward<_Args>(__args)...)); }
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from WPopupWidget Test.cpp:27:
/usr/include/Wt/WPopupWidget.h:51:3: note: candidate: 'Wt::WPopupWidget::WPopupWidget(std::unique_ptr<Wt::WWidget>)'
51 | WPopupWidget(std::unique_ptr<WWidget> impl);
| ^~~~~~~~~~~~
/usr/include/Wt/WPopupWidget.h:51:41: note: no known conversion for argument 1 from 'unique_ptr<Wt::WContainerWidget>' to 'unique_ptr<Wt::WWidget>'
51 | WPopupWidget(std::unique_ptr<WWidget> impl);
| ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
How do I properly pass the WContainerWidget to the WPopupWidget?
Replies (2)
RE: No known conversion from ‘unique_ptr<Wt::WContainerWidget>’ to ‘unique_ptr<Wt::WWidget>’ - Added by Bruce Toll about 4 years ago
Hi,
I think you may need to use std::move(containerPtr) as the argument.
RE: No known conversion from ‘unique_ptr<Wt::WContainerWidget>’ to ‘unique_ptr<Wt::WWidget>’ - Added by Harm about 4 years ago
Bruce Toll wrote:
Hi,
I think you may need to use std::move(containerPtr) as the argument.
Ah yes this is the solution, my code compiles now. Thanks!