nana
nana copied to clipboard
fundamental types needs move constructors
This does not work:
std::vector<nana::inputbox::integer> items;
items.emplace_back(nana::inputbox::integer{ "foo", 42, 1, 1000, 1 });
As no move constructor is available for the nana fundamental types, and all of these contain:
std::unique_ptr<implement> impl_;
https://sourceforge.net/p/nanapro/blog/2013/05/why-should-not-a-widget-be-copyable-or-movable/
try:
std::vector<std::unique_ptr<nana::inputbox::integer>> items;
Indeed, the devil is in the details. However your suggested fix did not solve the problem:
Severity Code Description Project File Line Suppression State
Error C2664 'std::unique_ptr<nana::inputbox::integer,std::default_delete<_Ty>>::unique_ptr(const std::unique_ptr<_Ty,std::default_delete<_Ty>> &)': cannot convert argument 1 from '_Ty' to 'std::nullptr_t'
with
[
_Ty=nana::inputbox::integer
] ds2 C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.22.27905\include\xmemory 761
Severity Code Description Project File Line Suppression State
Error C2440 'initializing': cannot convert from '_Ty' to '_Objty'
with
[
_Ty=std::unique_ptr<nana::inputbox::integer,std::default_delete<nana::inputbox::integer>> *
]
and
[
_Objty=nana::inputbox::abstract_content *
] ds2 C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.22.27905\include\xmemory 761
Thanks for your feedback! As @qPCR4vir mentioned, a widget should not be copyable and movable. But I checked the implementations of inputbox::integer/boolean/text/...
classes, they can be designed to be movable.
A workaround, use deque/list, because nana::inputbox::integer
has std::unique_ptr
member which is not copyable.
std::deque<nana::inputbox::integer> items;
items.emplace_back( "foo", 42, 1, 1000, 1 );