diff --git a/include/nana/pat/abstract_factory.hpp b/include/nana/pat/abstract_factory.hpp index 9a4b3bfe..8aa44e7f 100644 --- a/include/nana/pat/abstract_factory.hpp +++ b/include/nana/pat/abstract_factory.hpp @@ -15,6 +15,8 @@ #define NANA_PAT_ABSFACTORY_HPP #include "cloneable.hpp" #include +#include +#include namespace nana { @@ -43,21 +45,73 @@ namespace nana namespace detail { - template + template + struct pack{ + using type = pack; + }; + + template + struct make_pack_helper + { // explodes gracefully below 0 + static_assert(!Negative, + "make_integer_sequence requires N to be non-negative."); + }; + + template + struct make_pack_helper, + pack > + : pack + { // ends recursion at 0 + }; + + template + struct make_pack_helper, + pack > + : make_pack_helper, + pack > + { // counts down to 0 + }; + + template + using make_pack = typename make_pack_helper, pack >::type; + + template class abs_factory : public abstract_factory { std::unique_ptr create() override { - return std::unique_ptr{ new T }; + constexpr auto Size = std::tuple_size::value; + return std::unique_ptr{ _m_new(typename make_pack{}) }; } + + template + Interface* _m_new(const pack &) + { + return new T(std::get(args_)...); + } + public: + abs_factory(Args&&... args) + : args_(std::forward(args)...) + { + } + + abs_factory(const Args&... args) + : args_(args...) + { + } + private: + std::tuple args_; }; }//end namespace detail - template - pat::cloneable> make_factory() + template + pat::cloneable> make_factory(Args &&... args) { - return detail::abs_factory(); + return detail::abs_factory::type...>(std::forward(args)...); } }//end namespace pat }//end namespace nana diff --git a/include/nana/pat/cloneable.hpp b/include/nana/pat/cloneable.hpp index c6f5d1c9..350dbe1a 100644 --- a/include/nana/pat/cloneable.hpp +++ b/include/nana/pat/cloneable.hpp @@ -1,7 +1,7 @@ /* * A Generic Cloneable Pattern Implementation * Nana C++ Library(http://www.nanapro.org) -* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com) +* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com) * * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at @@ -106,8 +106,8 @@ namespace nana{ namespace pat{ template::type* = nullptr> cloneable(T&& t) - : cwrapper_(new detail::cloneable_wrapper::type>::type>(std::forward(t)), detail::cloneable_interface_deleter()), - fast_ptr_(reinterpret_cast::type>::type*>(cwrapper_->get())) + : cwrapper_(new detail::cloneable_wrapper::type>(std::forward(t)), detail::cloneable_interface_deleter()), + fast_ptr_(reinterpret_cast::type*>(cwrapper_->get())) {} cloneable(const cloneable& r) diff --git a/source/gui/widgets/listbox.cpp b/source/gui/widgets/listbox.cpp index 98dd3732..1dcb7f9d 100644 --- a/source/gui/widgets/listbox.cpp +++ b/source/gui/widgets/listbox.cpp @@ -2140,8 +2140,6 @@ namespace nana enum class item_state{normal, highlighted, pressed, grabbed, floated}; enum class parts{unknown = -1, header, lister, checker}; - using inline_pane = inline_pane; - ::nana::listbox* listbox_ptr{nullptr}; ::nana::listbox::scheme_type* scheme_ptr{nullptr}; ::nana::paint::graphics *graph{nullptr}; @@ -3021,7 +3019,7 @@ namespace nana { } - void attach(index_type pos, essence::inline_pane* pane) + void attach(index_type pos, inline_pane* pane) { for (auto & pn : panes_) { @@ -3093,7 +3091,7 @@ namespace nana private: essence * const ess_; const std::size_t column_pos_; - std::vector> panes_; + std::vector> panes_; }; void es_lister::scroll(const index_pair& pos, bool to_bottom) @@ -3956,7 +3954,7 @@ namespace nana _m_draw_border(content_r.x, y, show_w); } - essence::inline_pane * _m_get_inline_pane(const category_t& cat, std::size_t column_pos) const + inline_pane * _m_get_inline_pane(const category_t& cat, std::size_t column_pos) const { if (column_pos < cat.factories.size()) { @@ -3969,7 +3967,7 @@ namespace nana return nullptr; } - essence::inline_pane* _m_find_inline_pane(const index_pair& pos, std::size_t column_pos) const + inline_pane* _m_find_inline_pane(const index_pair& pos, std::size_t column_pos) const { auto & cat = *essence_->lister.get(pos.cat);