apply folding expression and std::optional
This commit is contained in:
@@ -204,6 +204,7 @@
|
||||
# define _nana_cxx_constexpr_if
|
||||
# define _nana_cxx_folding_expression
|
||||
# define _nana_cxx_nested_namespace_definition
|
||||
# define _nana_std_optional
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -14,7 +14,11 @@
|
||||
#define NANA_WIDGET_CONTENT_MEASURER_INTERFACE_HEADER_INCLUDED
|
||||
|
||||
#include <nana/basic_types.hpp>
|
||||
#include <nana/optional.hpp>
|
||||
#ifdef _nana_std_optional
|
||||
# include <optional>
|
||||
#else
|
||||
# include <nana/optional.hpp>
|
||||
#endif
|
||||
#include <nana/paint/graphics.hpp>
|
||||
|
||||
namespace nana
|
||||
@@ -35,7 +39,7 @@ namespace nana
|
||||
* @param limit_width True if limits the width, false if limits the height.
|
||||
* @return the size of content.
|
||||
*/
|
||||
virtual optional<size> measure(graph_reference graph, unsigned limit_pixels, bool limit_width) const = 0;
|
||||
virtual ::std::optional<size> measure(graph_reference graph, unsigned limit_pixels, bool limit_width) const = 0;
|
||||
|
||||
/// Returns the extension to the size of widget from content extent
|
||||
/**
|
||||
|
||||
@@ -461,7 +461,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<std::pair<::nana::size, ::nana::size>> content_extent(window wd, unsigned limited_px, bool limit_width);
|
||||
std::optional<std::pair<::nana::size, ::nana::size>> content_extent(window wd, unsigned limited_px, bool limit_width);
|
||||
}//end namespace API
|
||||
|
||||
}//end namespace nana
|
||||
|
||||
@@ -34,7 +34,12 @@ namespace nana
|
||||
::std::string get(std::string msgid_utf8, Args&&... args) const
|
||||
{
|
||||
std::vector<std::string> arg_strs;
|
||||
|
||||
#ifdef _nana_cxx_folding_expression
|
||||
(_m_fetch_args(arg_strs, std::forward<Args>(args)),...);
|
||||
#else
|
||||
_m_fetch_args(arg_strs, std::forward<Args>(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<std::string>&) const; //Termination of _m_fetch_args
|
||||
#ifndef _nana_cxx_folding_expression
|
||||
static void _m_fetch_args(std::vector<std::string>&); //Termination of _m_fetch_args
|
||||
#endif
|
||||
|
||||
void _m_fetch_args(std::vector<std::string>& v, const char* arg) const;
|
||||
void _m_fetch_args(std::vector<std::string>& v, const std::string& arg) const;
|
||||
void _m_fetch_args(std::vector<std::string>& v, std::string& arg) const;
|
||||
void _m_fetch_args(std::vector<std::string>& v, std::string&& arg) const;
|
||||
void _m_fetch_args(std::vector<std::string>& v, const wchar_t* arg) const;
|
||||
void _m_fetch_args(std::vector<std::string>& v, const std::wstring& arg) const;
|
||||
void _m_fetch_args(std::vector<std::string>& v, std::wstring& arg) const;
|
||||
void _m_fetch_args(std::vector<std::string>& v, std::wstring&& arg) const;
|
||||
static void _m_fetch_args(std::vector<std::string>& v, const char* arg);
|
||||
static void _m_fetch_args(std::vector<std::string>& v, const std::string& arg);
|
||||
static void _m_fetch_args(std::vector<std::string>& v, std::string& arg);
|
||||
static void _m_fetch_args(std::vector<std::string>& v, std::string&& arg);
|
||||
static void _m_fetch_args(std::vector<std::string>& v, const wchar_t* arg);
|
||||
static void _m_fetch_args(std::vector<std::string>& v, const std::wstring& arg);
|
||||
static void _m_fetch_args(std::vector<std::string>& v, std::wstring& arg);
|
||||
static void _m_fetch_args(std::vector<std::string>& v, std::wstring&& arg);
|
||||
|
||||
template<typename Arg>
|
||||
void _m_fetch_args(std::vector<std::string>& v, Arg&& arg) const
|
||||
static void _m_fetch_args(std::vector<std::string>& v, Arg&& arg)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << arg;
|
||||
v.emplace_back(ss.str());
|
||||
}
|
||||
|
||||
#ifndef _nana_cxx_folding_expression
|
||||
template<typename ...Args>
|
||||
void _m_fetch_args(std::vector<std::string>& 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>(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 _nana_cxx_folding_expression
|
||||
(_m_fetch_args(std::forward<Args>(args)), ...);
|
||||
#else
|
||||
_m_fetch_args(std::forward<Args>(args)...);
|
||||
#endif
|
||||
}
|
||||
|
||||
i18n_eval(const i18n_eval&);
|
||||
@@ -193,6 +206,7 @@ namespace nana
|
||||
|
||||
std::string operator()() const;
|
||||
private:
|
||||
#ifndef _nana_cxx_folding_expression
|
||||
void _m_fetch_args(){} //Termination of _m_fetch_args
|
||||
|
||||
template<typename Arg, typename ...Args>
|
||||
@@ -201,6 +215,7 @@ namespace nana
|
||||
_m_add_args(std::forward<Arg>(arg));
|
||||
_m_fetch_args(std::forward<Args>(args)...);
|
||||
}
|
||||
#endif
|
||||
|
||||
template<typename Arg>
|
||||
void _m_add_args(Arg&& arg)
|
||||
|
||||
@@ -15,8 +15,11 @@
|
||||
#ifndef NANA_STD_OPTIONAL_HEADER_INCLUDED
|
||||
#define NANA_STD_OPTIONAL_HEADER_INCLUDED
|
||||
|
||||
#include <stdexcept>
|
||||
#include <nana/c++defines.hpp>
|
||||
|
||||
#ifndef _nana_std_optional
|
||||
#include <stdexcept>
|
||||
|
||||
namespace nana
|
||||
{
|
||||
namespace detail
|
||||
@@ -361,4 +364,9 @@ namespace nana
|
||||
};
|
||||
}
|
||||
|
||||
namespace std
|
||||
{
|
||||
using nana::optional;
|
||||
}
|
||||
#endif //_nana_std_optional
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user