diff --git a/include/nana/c++defines.hpp b/include/nana/c++defines.hpp index 1613f9b8..850113b8 100644 --- a/include/nana/c++defines.hpp +++ b/include/nana/c++defines.hpp @@ -36,9 +36,9 @@ * - STD_TO_STRING_NOT_SUPPORTED (MinGW with GCC < 4.8) * - STD_FILESYSTEM_NOT_SUPPORTED (GCC < 5.3) .... * - CXX_NO_INLINE_NAMESPACE (Visual C++ < 2015) - * - _enable_std_make_unique (__cpluscplus < 201402) - * - _enable_std_put_time (GCC < 5) - * - _enable_std_clamp (Visual C++ < 2017) + * - _nana_std_make_unique (__cpluscplus < 201402) + * - _nana_std_put_time (GCC < 5) + * - _nana_std_clamp (Visual C++ < 2017) */ #ifndef NANA_CXX_DEFINES_INCLUDED @@ -145,7 +145,7 @@ # if ((__GNUC__ < 5) ) -# define _enable_std_put_time +# define _nana_std_put_time # endif # if ((__GNUC__ > 5) || ((__GNUC__ == 5) && (__GNUC_MINOR__ >= 3 ) ) ) @@ -189,20 +189,28 @@ //Detects the feature std::make_unique //std::make_unique has been provided by Visual C++ 2013 and later -#undef _enable_std_make_unique +#undef _nana_std_make_unique #if (defined(__clang__) && (__cplusplus < 201305L || (__cplusplus == 201305L && (__clang_major__ * 100 + __clang_minor__ < 304 )))) \ || ((!defined(__clang__)) && defined(__GNUC__) && __cplusplus < 201300L) -# define _enable_std_make_unique +# define _nana_std_make_unique #endif //Detects the feature std::clamp //Visual C++ 2017 with /std:c++latest provides the std::clamp -#undef _enable_std_clamp +#undef _nana_std_clamp #if (defined(_MSC_VER) && ((!defined(_MSVC_LANG)) || _MSVC_LANG < 201403L)) \ || (defined(__clang__) && (__cplusplus < 201406L)) \ || (defined(__GNUC__) && (!defined(__clang__)) && (__cplusplus < 201703)) -# define _enable_std_clamp +# define _nana_std_clamp +#endif + + +#undef _nana_std_optional +#if ((defined(_MSC_VER) && (_MSC_VER >= 1912) && defined(_MSVC_LANG) && _MSVC_LANG>= 201703)) || \ + (defined(__clang__) && (__clang_major__ * 100 + __clang_minor__ >= 400)) || \ + (!defined(__clang__) && defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 701) +# define _nana_std_optional #endif diff --git a/include/nana/filesystem/filesystem_ext.hpp b/include/nana/filesystem/filesystem_ext.hpp index 40eb1f60..ca579e8e 100644 --- a/include/nana/filesystem/filesystem_ext.hpp +++ b/include/nana/filesystem/filesystem_ext.hpp @@ -35,14 +35,14 @@ namespace filesystem_ext std::experimental::filesystem::path path_user(); ///< extention ? -/// workaround Boost not having path.generic_u8string() - a good point for http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0251r0.pdf -inline std::string generic_u8string(const std::experimental::filesystem::path& p) -{ - #if NANA_USING_BOOST_FILESYSTEM - return nana::to_utf8(p.generic_wstring()); - #else - return p.generic_u8string(); - #endif + /// workaround Boost not having path.generic_u8string() - a good point for http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0251r0.pdf +inline std::string generic_u8string(const std::experimental::filesystem::path& p) +{ +#if NANA_USING_BOOST_FILESYSTEM + return nana::to_utf8(p.generic_wstring()); +#else + return p.generic_u8string(); +#endif } inline bool is_directory(const std::experimental::filesystem::directory_entry& dir) noexcept diff --git a/include/nana/gui/detail/general_events.hpp b/include/nana/gui/detail/general_events.hpp index 72b4cbf3..0a4881b4 100644 --- a/include/nana/gui/detail/general_events.hpp +++ b/include/nana/gui/detail/general_events.hpp @@ -133,11 +133,25 @@ namespace nana /// Creates an event handler at the beginning of event chain template event_handle connect_front(Function && fn) - { + { +#ifdef __cpp_if_constexpr + if constexpr(std::is_invocable_v) + { + return _m_emplace(new docker{ this, fn, false }, true); + } + else if constexpr(std::is_invocable_v) + { + return _m_emplace(new docker{ this, [fn](arg_reference) { + fn(); + }, false }, true); + } +#else using prototype = typename std::remove_reference::type; return _m_emplace(new docker(this, factory::value>::build(std::forward(fn)), false), true); +#endif } +#ifndef __cpp_if_constexpr /// It will not get called if stop_propagation() was called. event_handle connect(void (*fn)(arg_reference)) { @@ -145,13 +159,27 @@ namespace nana fn(arg); }); } +#endif /// It will not get called if stop_propagation() was called, because it is set at the end of the chain.. template event_handle connect(Function && fn) { +#ifdef __cpp_if_constexpr + if constexpr(std::is_invocable_v) + { + return _m_emplace(new docker{ this, fn, false }, false); + } + else if constexpr(std::is_invocable_v) + { + return _m_emplace(new docker{ this, [fn](arg_reference){ + fn(); + }, false }, false); + } +#else using prototype = typename std::remove_reference::type; return _m_emplace(new docker(this, factory::value>::build(std::forward(fn)), false), false); +#endif } /// It will not get called if stop_propagation() was called. @@ -164,10 +192,22 @@ namespace nana /// It will get called because it is unignorable. template event_handle connect_unignorable(Function && fn, bool in_front = false) - { + { +#ifdef __cpp_if_constexpr + if constexpr(std::is_invocable_v) + { + return _m_emplace(new docker{ this, fn, true }, in_front); + } + else if constexpr(std::is_invocable_v) + { + return _m_emplace(new docker{ this, [fn](arg_reference) { + fn(); + }, true }, in_front); + } +#else using prototype = typename std::remove_reference::type; - return _m_emplace(new docker(this, factory::value>::build(std::forward(fn)), true), in_front); +#endif } void emit(arg_reference& arg, window window_handle) @@ -210,6 +250,8 @@ namespace nana } } private: + +#ifndef __cpp_if_constexpr template struct factory { @@ -385,6 +427,7 @@ namespace nana }; } }; +#endif }; struct arg_mouse diff --git a/include/nana/gui/detail/widget_content_measurer_interface.hpp b/include/nana/gui/detail/widget_content_measurer_interface.hpp index 4f175493..ca0f5a55 100644 --- a/include/nana/gui/detail/widget_content_measurer_interface.hpp +++ b/include/nana/gui/detail/widget_content_measurer_interface.hpp @@ -35,7 +35,7 @@ namespace nana * @param limit_width True if limits the width, false if limits the height. * @return the size of content. */ - virtual optional measure(graph_reference graph, unsigned limit_pixels, bool limit_width) const = 0; + virtual ::std::optional measure(graph_reference graph, unsigned limit_pixels, bool limit_width) const = 0; /// Returns the extension to the size of widget from content extent /** diff --git a/include/nana/gui/msgbox.hpp b/include/nana/gui/msgbox.hpp index 67840f1a..02b4fe35 100644 --- a/include/nana/gui/msgbox.hpp +++ b/include/nana/gui/msgbox.hpp @@ -240,7 +240,11 @@ namespace nana bool show(Args&& ... args) { std::vector contents; +#ifdef __cpp_fold_expressions + (contents.emplace_back(&args), ...); +#else _m_fetch_args(contents, std::forward(args)...); +#endif if (contents.empty()) return false; @@ -270,6 +274,7 @@ namespace nana void min_width_entry_field( unsigned pixels ); private: +#ifndef __cpp_fold_expressions void _m_fetch_args(std::vector&); template @@ -278,6 +283,7 @@ namespace nana contents.push_back(&content); _m_fetch_args(contents, std::forward(args)...); } +#endif bool _m_open(std::vector&, bool modal); private: diff --git a/include/nana/gui/programming_interface.hpp b/include/nana/gui/programming_interface.hpp index 7d7e0538..134b0082 100644 --- a/include/nana/gui/programming_interface.hpp +++ b/include/nana/gui/programming_interface.hpp @@ -89,7 +89,7 @@ namespace API void set_measurer(window, ::nana::dev::widget_content_measurer_interface*); void attach_drawer(widget&, drawer_trigger&); - ::nana::detail::native_string_type window_caption(window) throw(); + ::nana::detail::native_string_type window_caption(window) noexcept; void window_caption(window, ::nana::detail::native_string_type); window create_window(window, bool nested, const rectangle&, const appearance&, widget* attached); @@ -255,6 +255,19 @@ namespace API if (nullptr == general_evt) throw std::invalid_argument("API::events(): bad parameter window handle, no events object or invalid window handle."); +#ifdef __cpp_if_constexpr + if constexpr(std::is_same_v) + { + return *general_evt; + } + else + { + auto * widget_evt = dynamic_cast(general_evt); + if (nullptr == widget_evt) + throw std::invalid_argument("API::events(): bad template parameter Widget, the widget type and window handle do not match."); + return *widget_evt; + } +#else if (std::is_same<::nana::general_events, event_type>::value) return *static_cast(general_evt); @@ -262,6 +275,7 @@ namespace API if (nullptr == widget_evt) throw std::invalid_argument("API::events(): bad template parameter Widget, the widget type and window handle do not match."); return *widget_evt; +#endif } template::value>::type* = nullptr> @@ -288,6 +302,19 @@ namespace API if (nullptr == wdg_colors) throw std::invalid_argument("API::scheme(): bad parameter window handle, no events object or invalid window handle."); +#ifdef __cpp_if_constexpr + if constexpr(std::is_same<::nana::widget_geometrics, scheme_type>::value) + { + return *static_cast(wdg_colors); + } + else + { + auto * comp_wdg_colors = dynamic_cast(wdg_colors); + if (nullptr == comp_wdg_colors) + throw std::invalid_argument("API::scheme(): bad template parameter Widget, the widget type and window handle do not match."); + return *comp_wdg_colors; + } +#else if (std::is_same<::nana::widget_geometrics, scheme_type>::value) return *static_cast(wdg_colors); @@ -295,6 +322,7 @@ namespace API if (nullptr == comp_wdg_colors) throw std::invalid_argument("API::scheme(): bad template parameter Widget, the widget type and window handle do not match."); return *comp_wdg_colors; +#endif } point window_position(window); @@ -312,7 +340,7 @@ namespace API size window_outline_size(window); void window_outline_size(window, const size&); - nana::optional window_rectangle(window); + ::std::optional window_rectangle(window); bool get_window_rectangle(window, rectangle&); bool track_window_size(window, const size&, bool true_for_max); ///< Sets the minimum or maximum tracking size of a window. void window_enabled(window, bool); @@ -434,7 +462,7 @@ namespace API bool ignore_mouse_focus(window, bool ignore); ///< Enables/disables the mouse focus, it returns the previous state bool ignore_mouse_focus(window); ///< Determines whether the mouse focus is enabled - void at_safe_place(window, std::function); + void at_safe_place(window, ::std::function); /// Returns a widget content extent size /** @@ -445,7 +473,7 @@ namespace API * @return if optional has a value, the first size indicates the content extent, the second size indicates the size of * widget by the content extent. */ - optional> content_extent(window wd, unsigned limited_px, bool limit_width); + ::std::optional> content_extent(window wd, unsigned limited_px, bool limit_width); unsigned screen_dpi(bool x_requested); }//end namespace API diff --git a/include/nana/gui/widgets/combox.hpp b/include/nana/gui/widgets/combox.hpp index fc8e4522..551c65d3 100644 --- a/include/nana/gui/widgets/combox.hpp +++ b/include/nana/gui/widgets/combox.hpp @@ -223,7 +223,7 @@ namespace nana const drawerbase::combox::drawer_impl& _m_impl() const; private: //Overrides widget's virtual functions - native_string_type _m_caption() const throw() override; + native_string_type _m_caption() const noexcept override; void _m_caption(native_string_type&&) override; nana::any * _m_anyobj(std::size_t pos, bool alloc_if_empty) const override; }; diff --git a/include/nana/gui/widgets/detail/widget_iterator.hpp b/include/nana/gui/widgets/detail/widget_iterator.hpp new file mode 100644 index 00000000..c78e5d4d --- /dev/null +++ b/include/nana/gui/widgets/detail/widget_iterator.hpp @@ -0,0 +1,36 @@ +/* + * A Widget Iterator Template + * Copyright(C) 2017 Jinhao(cnjinhao@hotmail.com) + * + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + * + * @file: nana/gui/widgets/detail/widget_iterator.hpp + * @description: widget_iterator is the base class provided to simplify definitions of the required types for widget iterators. + * It is provided because of deprecation of std::iterator in C++17 + */ +#ifndef NANA_GUI_WIDGET_ITERATOR_INCLUDED +#define NANA_GUI_WIDGET_ITERATOR_INCLUDED + +#include //provides std::ptrdiff_t + + +namespace nana { + namespace widgets { + namespace detail + { + template + class widget_iterator + { + using iterator_category = Category; + using value_type = T; + using difference_type = std::ptrdiff_t; + using pointer = T * ; + using reference = T & ; + }; + } + } +} + +#endif diff --git a/include/nana/gui/widgets/group.hpp b/include/nana/gui/widgets/group.hpp index 6ec70c0a..86ca663b 100644 --- a/include/nana/gui/widgets/group.hpp +++ b/include/nana/gui/widgets/group.hpp @@ -83,7 +83,7 @@ namespace nana{ void _m_add_child(const char* field, widget*); void _m_init(); void _m_complete_creation() override; - native_string_type _m_caption() const throw() override; + native_string_type _m_caption() const noexcept override; void _m_caption(native_string_type&&) override; private: std::unique_ptr impl_; diff --git a/include/nana/gui/widgets/label.hpp b/include/nana/gui/widgets/label.hpp index ee26383b..09d990e4 100644 --- a/include/nana/gui/widgets/label.hpp +++ b/include/nana/gui/widgets/label.hpp @@ -62,12 +62,12 @@ namespace nana label(window parent, const char* text, bool visible = true) :label(parent, std::string(text),visible) {}; label(window, const rectangle& = {}, bool visible = true); label& transparent(bool); ///< Switchs the label widget to the transparent background mode. - bool transparent() const throw(); + bool transparent() const noexcept; label& format(bool); ///< Switches the format mode of the widget. label& add_format_listener(std::function); /// as same as the HTML "for" attribute of a label - label& click_for(window associated_window) throw(); + label& click_for(window associated_window) noexcept; /// Returns the size of the text. If *allowed_width_in_pixel* is not zero, returns a /// "corrected" size that changes lines to fit the text into the specified width diff --git a/include/nana/gui/widgets/listbox.hpp b/include/nana/gui/widgets/listbox.hpp index 36a38f65..21f20856 100644 --- a/include/nana/gui/widgets/listbox.hpp +++ b/include/nana/gui/widgets/listbox.hpp @@ -23,6 +23,7 @@ #include "widget.hpp" #include "detail/inline_widget.hpp" +#include "detail/widget_iterator.hpp" #include #include #include @@ -808,7 +809,8 @@ namespace nana /// operate with absolute positions and contain only the position but montain pointers to parts of the real items /// item_proxy self, it references and iterators are not invalidated by sort() class item_proxy - : public std::iterator + //: public std::iterator //deprecated + : public ::nana::widgets::detail::widget_iterator { public: item_proxy(essence*, const index_pair& = index_pair{npos, npos}); @@ -982,7 +984,8 @@ namespace nana }; class cat_proxy - : public std::iterator < std::input_iterator_tag, cat_proxy > + //: public std::iterator //deprecated + : public ::nana::widgets::detail::widget_iterator { public: using inline_notifier_interface = drawerbase::listbox::inline_notifier_interface; diff --git a/include/nana/gui/widgets/spinbox.hpp b/include/nana/gui/widgets/spinbox.hpp index 542874f7..9595321f 100644 --- a/include/nana/gui/widgets/spinbox.hpp +++ b/include/nana/gui/widgets/spinbox.hpp @@ -116,7 +116,7 @@ namespace nana void modifier(std::string prefix_utf8, std::string suffix_utf8); void modifier(const std::wstring & prefix, const std::wstring& suffix); private: - native_string_type _m_caption() const throw(); + native_string_type _m_caption() const noexcept; void _m_caption(native_string_type&&); }; //end class spinbox }//end namespace nana diff --git a/include/nana/gui/widgets/tabbar.hpp b/include/nana/gui/widgets/tabbar.hpp index a24cce4a..17a57411 100644 --- a/include/nana/gui/widgets/tabbar.hpp +++ b/include/nana/gui/widgets/tabbar.hpp @@ -383,7 +383,7 @@ namespace nana driver(); ~driver(); - model* get_model() const throw(); + model* get_model() const noexcept; private: //Overrides drawer_trigger's method void attached(widget_reference, graph_reference) override; diff --git a/include/nana/gui/widgets/textbox.hpp b/include/nana/gui/widgets/textbox.hpp index 4a2663ae..c46aa1ca 100644 --- a/include/nana/gui/widgets/textbox.hpp +++ b/include/nana/gui/widgets/textbox.hpp @@ -276,7 +276,7 @@ namespace nana std::size_t text_line_count() const noexcept; protected: //Overrides widget's virtual functions - native_string_type _m_caption() const throw() override; + native_string_type _m_caption() const noexcept override; void _m_caption(native_string_type&&) override; void _m_typeface(const paint::font&) override; std::shared_ptr _m_scroll_operation() override; diff --git a/include/nana/gui/widgets/widget.hpp b/include/nana/gui/widgets/widget.hpp index 10a3e352..d7be3acf 100644 --- a/include/nana/gui/widgets/widget.hpp +++ b/include/nana/gui/widgets/widget.hpp @@ -54,9 +54,9 @@ namespace nana window parent() const; - ::std::string caption() const throw(); - ::std::wstring caption_wstring() const throw(); - native_string_type caption_native() const throw(); + ::std::string caption() const noexcept; + ::std::wstring caption_wstring() const noexcept; + native_string_type caption_native() const noexcept; widget& caption(std::string utf8); widget& caption(std::wstring); @@ -132,7 +132,7 @@ namespace nana virtual void _m_complete_creation(); virtual general_events& _m_get_general_events() const = 0; - virtual native_string_type _m_caption() const throw(); + virtual native_string_type _m_caption() const noexcept; virtual void _m_caption(native_string_type&&); virtual nana::cursor _m_cursor() const; virtual void _m_cursor(nana::cursor); diff --git a/include/nana/internationalization.hpp b/include/nana/internationalization.hpp index 4b3e3918..cab02568 100644 --- a/include/nana/internationalization.hpp +++ b/include/nana/internationalization.hpp @@ -34,7 +34,12 @@ namespace nana ::std::string get(std::string msgid_utf8, Args&&... args) const { std::vector arg_strs; + +#ifdef __cpp_fold_expressions + (_m_fetch_args(arg_strs, std::forward(args)),...); +#else _m_fetch_args(arg_strs, std::forward(args)...); +#endif auto msgstr = _m_get(std::move(msgid_utf8)); _m_replace_args(msgstr, &arg_strs); @@ -53,25 +58,28 @@ namespace nana std::string _m_get(std::string&& msgid) const; void _m_replace_args(::std::string& str, std::vector<::std::string> * arg_strs) const; - void _m_fetch_args(std::vector&) const; //Termination of _m_fetch_args +#ifndef __cpp_fold_expressions + static void _m_fetch_args(std::vector&); //Termination of _m_fetch_args +#endif - void _m_fetch_args(std::vector& v, const char* arg) const; - void _m_fetch_args(std::vector& v, const std::string& arg) const; - void _m_fetch_args(std::vector& v, std::string& arg) const; - void _m_fetch_args(std::vector& v, std::string&& arg) const; - void _m_fetch_args(std::vector& v, const wchar_t* arg) const; - void _m_fetch_args(std::vector& v, const std::wstring& arg) const; - void _m_fetch_args(std::vector& v, std::wstring& arg) const; - void _m_fetch_args(std::vector& v, std::wstring&& arg) const; + static void _m_fetch_args(std::vector& v, const char* arg); + static void _m_fetch_args(std::vector& v, const std::string& arg); + static void _m_fetch_args(std::vector& v, std::string& arg); + static void _m_fetch_args(std::vector& v, std::string&& arg); + static void _m_fetch_args(std::vector& v, const wchar_t* arg); + static void _m_fetch_args(std::vector& v, const std::wstring& arg); + static void _m_fetch_args(std::vector& v, std::wstring& arg); + static void _m_fetch_args(std::vector& v, std::wstring&& arg); template - void _m_fetch_args(std::vector& v, Arg&& arg) const + static void _m_fetch_args(std::vector& v, Arg&& arg) { std::stringstream ss; ss << arg; v.emplace_back(ss.str()); } +#ifndef __cpp_fold_expressions template void _m_fetch_args(std::vector& v, const char* arg, Args&&... args) const { @@ -136,6 +144,7 @@ namespace nana v.emplace_back(ss.str()); _m_fetch_args(v, std::forward(args)...); } +#endif };//end class internationalization class i18n_eval @@ -180,7 +189,11 @@ namespace nana i18n_eval(std::string msgid_utf8, Args&&... args) : msgid_(std::move(msgid_utf8)) { +#ifdef __cpp_fold_expressions + (_m_fetch_args(std::forward(args)), ...); +#else _m_fetch_args(std::forward(args)...); +#endif } i18n_eval(const i18n_eval&); @@ -193,6 +206,7 @@ namespace nana std::string operator()() const; private: +#ifndef __cpp_fold_expressions void _m_fetch_args(){} //Termination of _m_fetch_args template @@ -201,6 +215,7 @@ namespace nana _m_add_args(std::forward(arg)); _m_fetch_args(std::forward(args)...); } +#endif template void _m_add_args(Arg&& arg) diff --git a/include/nana/optional.hpp b/include/nana/optional.hpp index 49b81d88..1bb8373b 100644 --- a/include/nana/optional.hpp +++ b/include/nana/optional.hpp @@ -15,8 +15,13 @@ #ifndef NANA_STD_OPTIONAL_HEADER_INCLUDED #define NANA_STD_OPTIONAL_HEADER_INCLUDED -#include #include + +#ifdef _nana_std_optional +#include +#else +#include + namespace nana { namespace detail @@ -361,4 +366,10 @@ namespace nana }; } +namespace std +{ + using nana::optional; +} + +#endif //_nana_std_optional #endif diff --git a/include/nana/paint/graphics.hpp b/include/nana/paint/graphics.hpp index ad0ef379..f3b33aa5 100644 --- a/include/nana/paint/graphics.hpp +++ b/include/nana/paint/graphics.hpp @@ -156,7 +156,7 @@ namespace nana /// Saves images as a windows bitmap file /// @param file_utf8 A UTF-8 string to a filename - void save_as_file(const char* file_utf8) const throw(); + void save_as_file(const char* file_utf8) const noexcept; ::nana::color palette(bool for_text) const; graphics& palette(bool for_text, const ::nana::color&); diff --git a/include/nana/stdc++.hpp b/include/nana/stdc++.hpp index c21d8a94..54d62f73 100644 --- a/include/nana/stdc++.hpp +++ b/include/nana/stdc++.hpp @@ -86,7 +86,7 @@ namespace std } #endif -#ifdef _enable_std_make_unique +#ifdef _nana_std_make_unique // http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3656.htm #include @@ -124,9 +124,9 @@ namespace std { typename _Unique_if::_Known_bound make_unique(Args&&...) = delete; } -#endif //_enable_std_make_unique +#endif //_nana_std_make_unique -#ifdef _enable_std_put_time +#ifdef _nana_std_put_time #include #include namespace std @@ -144,9 +144,9 @@ namespace std //template<> //std::wstring put_time(const std::tm* tmb, const wchar_t* fmt); } -#endif // _enable_std_put_time +#endif // _nana_std_put_time -#if defined(_enable_std_clamp) +#if defined(_nana_std_clamp) namespace std { // since C++17 diff --git a/include/nana/verbose_preprocessor.hpp b/include/nana/verbose_preprocessor.hpp index b4804546..7f1d037c 100644 --- a/include/nana/verbose_preprocessor.hpp +++ b/include/nana/verbose_preprocessor.hpp @@ -80,7 +80,7 @@ #pragma message ( SHOW_VALUE(USE_github_com_meganz_mingw_std_threads) ) #pragma message ( SHOW_VALUE(NANA_ENABLE_MINGW_STD_THREADS_WITH_MEGANZ) ) #pragma message ( SHOW_VALUE(STD_THREAD_NOT_SUPPORTED) ) - #pragma message ( SHOW_VALUE(_enable_std_put_time) ) + #pragma message ( SHOW_VALUE(_nana_std_put_time) ) #pragma message ( SHOW_VALUE(STD_MAKE_UNIQUE_NOT_SUPPORTED) ) #pragma message ( SHOW_VALUE(STD_FILESYSTEM_NOT_SUPPORTED) ) diff --git a/source/filesystem/filesystem.cpp b/source/filesystem/filesystem.cpp index 5bac5a40..ee636f18 100644 --- a/source/filesystem/filesystem.cpp +++ b/source/filesystem/filesystem.cpp @@ -16,7 +16,7 @@ #include #include -#ifdef _enable_std_put_time +#ifdef _nana_std_put_time #include #else #include diff --git a/source/gui/msgbox.cpp b/source/gui/msgbox.cpp index 75ce6a23..36a7c202 100644 --- a/source/gui/msgbox.cpp +++ b/source/gui/msgbox.cpp @@ -1294,8 +1294,10 @@ namespace nana min_width_entry_field_pixels_ = pixels; } +#ifndef _nana_cxx_folding_expression void inputbox::_m_fetch_args(std::vector&) {} +#endif bool inputbox::_m_open(std::vector& contents, bool modal) { diff --git a/source/gui/programming_interface.cpp b/source/gui/programming_interface.cpp index da45698b..ed81cef7 100644 --- a/source/gui/programming_interface.cpp +++ b/source/gui/programming_interface.cpp @@ -260,7 +260,7 @@ namespace API } } - ::nana::detail::native_string_type window_caption(window wd) throw() + ::nana::detail::native_string_type window_caption(window wd) noexcept { auto const iwd = reinterpret_cast(wd); internal_scope_guard isg; @@ -838,7 +838,7 @@ namespace API } } - nana::optional window_rectangle(window wd) + std::optional window_rectangle(window wd) { auto iwd = reinterpret_cast(wd); internal_scope_guard lock; @@ -1476,7 +1476,7 @@ namespace API restrict::wd_manager().set_safe_place(reinterpret_cast(wd), std::move(fn)); } - optional> content_extent(window wd, unsigned limited_px, bool limit_width) + std::optional> content_extent(window wd, unsigned limited_px, bool limit_width) { auto iwd = reinterpret_cast(wd); internal_scope_guard lock; diff --git a/source/gui/widgets/button.cpp b/source/gui/widgets/button.cpp index fe6f19c7..b7d3214b 100644 --- a/source/gui/widgets/button.cpp +++ b/source/gui/widgets/button.cpp @@ -27,7 +27,7 @@ namespace nana{ namespace drawerbase : trigger_{ t } {} - optional measure(graph_reference graph, unsigned limit_pixels, bool /*limit_width*/) const override + std::optional measure(graph_reference graph, unsigned limit_pixels, bool /*limit_width*/) const override { //Button doesn't provide a support of vfit and hfit if (limit_pixels) diff --git a/source/gui/widgets/combox.cpp b/source/gui/widgets/combox.cpp index c9b6311d..dcaf5c43 100644 --- a/source/gui/widgets/combox.cpp +++ b/source/gui/widgets/combox.cpp @@ -90,7 +90,7 @@ namespace nana : drw_{ drwimpl } {} - optional measure(graph_reference graph, unsigned limit_pixels, bool /*limit_width*/) const override + std::optional measure(graph_reference graph, unsigned limit_pixels, bool /*limit_width*/) const override { //Combox doesn't provide a support of vfit and hfit if (limit_pixels) @@ -1037,7 +1037,7 @@ namespace nana API::refresh_window(*this); } - auto combox::_m_caption() const throw() -> native_string_type + auto combox::_m_caption() const noexcept -> native_string_type { internal_scope_guard lock; auto editor = _m_impl().editor(); diff --git a/source/gui/widgets/group.cpp b/source/gui/widgets/group.cpp index b3c2658d..23cc287c 100644 --- a/source/gui/widgets/group.cpp +++ b/source/gui/widgets/group.cpp @@ -271,7 +271,7 @@ namespace nana{ _m_init(); } - auto group::_m_caption() const throw() -> native_string_type + auto group::_m_caption() const noexcept -> native_string_type { return impl_->caption.caption_native(); } diff --git a/source/gui/widgets/label.cpp b/source/gui/widgets/label.cpp index 1d436f68..bf670c12 100644 --- a/source/gui/widgets/label.cpp +++ b/source/gui/widgets/label.cpp @@ -653,7 +653,7 @@ namespace nana : impl_{ impl } {} - optional measure(graph_reference graph, unsigned limit_pixels, bool limit_width) const override + std::optional measure(graph_reference graph, unsigned limit_pixels, bool limit_width) const override { //Label now doesn't support to measure content with a specified height. if (graph && ((0 == limit_pixels) || limit_width)) @@ -825,7 +825,7 @@ namespace nana return *this; } - bool label::transparent() const throw() + bool label::transparent() const noexcept { return API::is_transparent_background(*this); } @@ -849,7 +849,7 @@ namespace nana return *this; } - label& label::click_for(window associated_window) throw() + label& label::click_for(window associated_window) noexcept { get_drawer_trigger().impl()->for_associated_wd = associated_window; return *this; diff --git a/source/gui/widgets/picture.cpp b/source/gui/widgets/picture.cpp index 356072b9..cba8a75c 100644 --- a/source/gui/widgets/picture.cpp +++ b/source/gui/widgets/picture.cpp @@ -74,7 +74,7 @@ namespace nana : impl_{impl} {} - optional measure(graph_reference /*graph*/, unsigned limit_pixels, bool /*limit_width*/) const override + std::optional measure(graph_reference /*graph*/, unsigned limit_pixels, bool /*limit_width*/) const override { //Picture doesn't provide a support of vfit and hfit if (!limit_pixels) diff --git a/source/gui/widgets/spinbox.cpp b/source/gui/widgets/spinbox.cpp index af1288eb..6ed1f3ed 100644 --- a/source/gui/widgets/spinbox.cpp +++ b/source/gui/widgets/spinbox.cpp @@ -82,10 +82,39 @@ namespace nana bool check_value(const std::string& str) const override { +#ifdef __cpp_if_constexpr + auto i = str.c_str(); + if ('+' == *i || '-' == *i) + ++i; + + if constexpr(std::is_same::value) + { + for (; 0 != *i; ++i) + { + if (*i < '0' || '9' < *i) + return false; + } + } + else + { + bool dot = false; + for (; 0 != *i; ++i) + { + if (('.' == *i) && (!dot)) + { + dot = true; + continue; + } + + if (*i < '0' || '9' < *i) + return false; + } + } +#else if (str.empty()) return true; - auto size = str.size(); + auto const size = str.size(); std::size_t pos = 0; if (str[0] == '+' || str[0] == '-') pos = 1; @@ -115,6 +144,7 @@ namespace nana return false; } } +#endif return true; } @@ -744,7 +774,7 @@ namespace nana modifier(to_utf8(prefix), to_utf8(suffix)); } - auto spinbox::_m_caption() const throw() -> native_string_type + auto spinbox::_m_caption() const noexcept -> native_string_type { internal_scope_guard lock; auto editor = get_drawer_trigger().impl()->editor(); diff --git a/source/gui/widgets/tabbar.cpp b/source/gui/widgets/tabbar.cpp index ad614c09..2337f468 100644 --- a/source/gui/widgets/tabbar.cpp +++ b/source/gui/widgets/tabbar.cpp @@ -1533,7 +1533,7 @@ namespace nana delete model_; } - model* driver::get_model() const throw() + model* driver::get_model() const noexcept { return model_; } diff --git a/source/gui/widgets/textbox.cpp b/source/gui/widgets/textbox.cpp index 2fbc9290..db57ae82 100644 --- a/source/gui/widgets/textbox.cpp +++ b/source/gui/widgets/textbox.cpp @@ -785,7 +785,7 @@ namespace drawerbase { } //Override _m_caption for caption() - auto textbox::_m_caption() const throw() -> native_string_type + auto textbox::_m_caption() const noexcept -> native_string_type { internal_scope_guard lock; auto editor = get_drawer_trigger().editor(); diff --git a/source/gui/widgets/widget.cpp b/source/gui/widgets/widget.cpp index 3e3ab2cd..baf31f76 100644 --- a/source/gui/widgets/widget.cpp +++ b/source/gui/widgets/widget.cpp @@ -54,12 +54,12 @@ namespace nana widget& wdg_; }; - std::string widget::caption() const throw() + std::string widget::caption() const noexcept { return to_utf8(_m_caption()); } - std::wstring widget::caption_wstring() const throw() + std::wstring widget::caption_wstring() const noexcept { #if defined(NANA_WINDOWS) return _m_caption(); @@ -68,7 +68,7 @@ namespace nana #endif } - auto widget::caption_native() const throw() -> native_string_type + auto widget::caption_native() const noexcept -> native_string_type { return _m_caption(); } @@ -287,7 +287,7 @@ namespace nana void widget::_m_complete_creation() {} - auto widget::_m_caption() const throw() -> native_string_type + auto widget::_m_caption() const noexcept -> native_string_type { return API::dev::window_caption(handle()); } diff --git a/source/internationalization.cpp b/source/internationalization.cpp index 87c92437..4252d73c 100644 --- a/source/internationalization.cpp +++ b/source/internationalization.cpp @@ -414,45 +414,47 @@ namespace nana } } - void internationalization::_m_fetch_args(std::vector&) const +#ifndef _nana_cxx_folding_expression + void internationalization::_m_fetch_args(std::vector&) {} +#endif - void internationalization::_m_fetch_args(std::vector& v, const char* arg) const + void internationalization::_m_fetch_args(std::vector& v, const char* arg) { v.emplace_back(arg); } - void internationalization::_m_fetch_args(std::vector& v, const std::string& arg) const + void internationalization::_m_fetch_args(std::vector& v, const std::string& arg) { v.emplace_back(arg); } - void internationalization::_m_fetch_args(std::vector& v, std::string& arg) const + void internationalization::_m_fetch_args(std::vector& v, std::string& arg) { v.emplace_back(arg); } - void internationalization::_m_fetch_args(std::vector& v, std::string&& arg) const + void internationalization::_m_fetch_args(std::vector& v, std::string&& arg) { v.emplace_back(std::move(arg)); } - void internationalization::_m_fetch_args(std::vector& v, const wchar_t* arg) const + void internationalization::_m_fetch_args(std::vector& v, const wchar_t* arg) { v.emplace_back(to_utf8(arg)); } - void internationalization::_m_fetch_args(std::vector& v, const std::wstring& arg) const + void internationalization::_m_fetch_args(std::vector& v, const std::wstring& arg) { v.emplace_back(to_utf8(arg)); } - void internationalization::_m_fetch_args(std::vector& v, std::wstring& arg) const + void internationalization::_m_fetch_args(std::vector& v, std::wstring& arg) { v.emplace_back(to_utf8(arg)); } - void internationalization::_m_fetch_args(std::vector& v, std::wstring&& arg) const + void internationalization::_m_fetch_args(std::vector& v, std::wstring&& arg) { v.emplace_back(to_utf8(arg)); } diff --git a/source/paint/graphics.cpp b/source/paint/graphics.cpp index c021485d..2d92b435 100644 --- a/source/paint/graphics.cpp +++ b/source/paint/graphics.cpp @@ -937,7 +937,7 @@ namespace paint impl_->size.width = impl_->size.height = 0; } - void graphics::save_as_file(const char* file_utf8) const throw() + void graphics::save_as_file(const char* file_utf8) const noexcept { if(impl_->handle) { diff --git a/source/stdc++.cpp b/source/stdc++.cpp index 593ec334..2d2167ee 100644 --- a/source/stdc++.cpp +++ b/source/stdc++.cpp @@ -426,7 +426,7 @@ namespace std } #endif -#ifdef _enable_std_put_time +#ifdef _nana_std_put_time #include namespace std {