fix compiler errors using C++11

This commit is contained in:
Jinhao 2020-04-18 04:34:59 +08:00
parent d3e3e59812
commit e09b57ca12
2 changed files with 20 additions and 2 deletions

View File

@ -20,6 +20,7 @@
#include <list> #include <list>
#include <stack> #include <stack>
#include <stdexcept> #include <stdexcept>
#include <algorithm>
#include <nana/push_ignore_diagnostic> #include <nana/push_ignore_diagnostic>
#include <nana/unicode_bidi.hpp> #include <nana/unicode_bidi.hpp>

View File

@ -2,6 +2,9 @@
#include <set> #include <set>
#include <nana/deploy.hpp> #include <nana/deploy.hpp>
#include "../paint/truetype.hpp" #include "../paint/truetype.hpp"
#ifdef _nana_std_has_string_view
# include <string_view>
#endif
#ifdef NANA_WINDOWS #ifdef NANA_WINDOWS
@ -260,8 +263,13 @@ namespace nana
auto pbuf = pxbuf.get(); auto pbuf = pxbuf.get();
#ifdef _nana_std_has_string_view
std::wstring_view s{str, len};
#else
std::wstring s{str, len};
#endif
//Don't reverse the string //Don't reverse the string
_m_reorder_reshaping(std::wstring_view{str, len}, false, [&,xft, str](const wchar_t* p, std::size_t size, const wchar_t* pstr) mutable{ _m_reorder_reshaping(s, false, [&,xft, str](const wchar_t* p, std::size_t size, const wchar_t* pstr) mutable{
while(true) while(true)
{ {
auto preferred = _m_scan_fonts(xft, p, size, glyph_indexes.get()); auto preferred = _m_scan_fonts(xft, p, size, glyph_indexes.get());
@ -289,8 +297,13 @@ namespace nana
std::unique_ptr<FT_UInt[]> glyph_indexes(new FT_UInt[len]); std::unique_ptr<FT_UInt[]> glyph_indexes(new FT_UInt[len]);
#ifdef _nana_std_has_string_view
std::wstring_view s{str, len};
#else
std::wstring s{str, len};
#endif
//Don't reverse the string //Don't reverse the string
_m_reorder_reshaping(std::wstring_view{str, len}, false, [&,xft, str](const wchar_t* p, std::size_t size, const wchar_t* /*pstr*/) mutable{ _m_reorder_reshaping(s, false, [&,xft, str](const wchar_t* p, std::size_t size, const wchar_t* /*pstr*/) mutable{
while(true) while(true)
{ {
auto preferred = _m_scan_fonts(xft, p, size, glyph_indexes.get()); auto preferred = _m_scan_fonts(xft, p, size, glyph_indexes.get());
@ -313,7 +326,11 @@ namespace nana
private: private:
/// @param reverse Indicates whether to reverse the string, it only reverse the RTL language string. /// @param reverse Indicates whether to reverse the string, it only reverse the RTL language string.
template<typename Function> template<typename Function>
#ifdef _nana_std_has_string_view
void _m_reorder_reshaping(std::wstring_view str, bool reverse, Function fn) void _m_reorder_reshaping(std::wstring_view str, bool reverse, Function fn)
#else
void _m_reorder_reshaping(const std::wstring& str, bool reverse, Function fn)
#endif
{ {
//The RTL and shaping should be handled manually, because the libXft and X doesn't support these language features. //The RTL and shaping should be handled manually, because the libXft and X doesn't support these language features.
std::wstring rtl; std::wstring rtl;