add std::clamp

This commit is contained in:
Jinhao 2017-02-05 08:32:47 +08:00
parent 8e53602c79
commit 2fd3aa5030
7 changed files with 47 additions and 627 deletions

View File

@ -1,13 +1,13 @@
/**
* Predefined Symbols for C++
* Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2016 Jinhao(cnjinhao@hotmail.com)
* Copyright(C) 2016-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/config.hpp
* @file nana/c++defines.hpp
*
* @brief Provide switches to adapt to the target OS, use of external libraries or workarounds compiler errors or lack of std C++ support.
*
@ -31,13 +31,14 @@
* - _SCL_SECURE_NO_WARNNGS, _CRT_SECURE_NO_DEPRECATE (VC)
* - STD_CODECVT_NOT_SUPPORTED (VC RC, <codecvt> is a known issue on libstdc++, it works on libc++)
* - STD_THREAD_NOT_SUPPORTED (GCC < 4.8.1)
* - STD_put_time_NOT_SUPPORTED (GCC < 5)
* - STD_NUMERIC_CONVERSIONS_NOT_SUPPORTED (MinGW with GCC < 4.8.1)
* - STD_NUMERIC_CONVERSIONS_NOT_SUPPORTED (MinGW with GCC < 4.8.1)
* - STD_TO_STRING_NOT_SUPPORTED (MinGW with GCC < 4.8)
* - STD_FILESYSTEM_NOT_SUPPORTED (GCC < 5.3) ....
* - CXX_NO_INLINE_NAMESPACE (Visual C++ < 2015)
* - STD_MAKE_UNIQUE_NOT_SUPPORTED (GCC < 4.9)
* - _enable_std_make_unique (GCC < 4.9)
* - _enable_std_put_time (GCC < 5)
* - _enable_std_clamp (Visual C++ < 2017)
*/
#ifndef NANA_CXX_DEFINES_INCLUDED
@ -57,7 +58,7 @@
# define CXX_NO_INLINE_NAMESPACE //no support of C++11 inline namespace until Visual C++ 2015
# define noexcept //no support of noexcept until Visual C++ 2015
# define constexpr const //no support of constexpr until Visual C++ 2015 ? const ??
# define constexpr //no support of constexpr until Visual C++ 2015 ? const ??
# else
# undef STD_FILESYSTEM_NOT_SUPPORTED
# endif
@ -102,14 +103,18 @@
#define _CRT_SECURE_NO_DEPRECATE
#pragma warning(disable : 4996)
#if (_MSC_VER >= 1900)
# if (_MSC_VER >= 1900)
// google: break any code that tries to use codecvt<char16_t> or codecvt<char32_t>.
// google: It appears the C++ libs haven't been compiled with native char16_t/char32_t support.
// google: Those definitions are for codecvt<wchar_t>::id, codecvt<unsigned short>::id and codecvt<char>::id respectively.
// However, the codecvt<char16_t>::id and codecvt<char32_t>::id definitions aren't there, and indeed, if you look at locale0.cpp in the CRT source code you'll see they're not defined at all.
// google: That's a known issue, tracked by an active bug (DevDiv#1060849). We were able to update the STL's headers in response to char16_t/char32_t, but we still need to update the separately compiled sources.
#define STD_CODECVT_NOT_SUPPORTED
#endif // _MSC_VER == 1900
# define STD_CODECVT_NOT_SUPPORTED
# endif // _MSC_VER == 1900
# if (_MSC_VER < 1910) //VS2017 RTM
# define _enable_std_clamp
# endif
#elif defined(__clang__) //Clang
@ -119,13 +124,15 @@
#define STD_CODECVT_NOT_SUPPORTED
#if !defined(__cpp_lib_make_unique) || (__cpp_lib_make_unique != 201304)
#ifndef STD_MAKE_UNIQUE_NOT_SUPPORTED
#define STD_MAKE_UNIQUE_NOT_SUPPORTED
#ifndef _enable_std_make_unique
#define _enable_std_make_unique
#endif
#endif
#endif
# define _enable_std_clamp
#elif defined(__GNUC__) //GCC
#include <iosfwd> //Introduces some implement-specific flags of ISO C++ Library
@ -145,9 +152,9 @@
#endif
#if ((__GNUC__ < 5) )
# define STD_put_time_NOT_SUPPORTED
#endif
# if ((__GNUC__ < 5) )
# define _enable_std_put_time
# endif
#if ((__GNUC__ > 5) || ((__GNUC__ == 5) && (__GNUC_MINOR__ >= 3 ) ) )
# undef STD_FILESYSTEM_NOT_SUPPORTED
@ -160,7 +167,7 @@
#endif
#if (__GNUC_MINOR__ < 9)
#define STD_MAKE_UNIQUE_NOT_SUPPORTED
#define _enable_std_make_unique
#endif
#if defined(NANA_MINGW)
@ -181,6 +188,8 @@
#endif
#endif
#endif
# define _enable_std_clamp
#endif

View File

@ -17,98 +17,12 @@
#include <nana/push_ignore_diagnostic>
#include <nana/config.hpp>
#include <nana/stdc++.hpp>
#include <stdexcept>
#include <nana/charset.hpp>
//Implement workarounds for GCC/MinGW which version is below 4.8.2
#if defined(STD_NUMERIC_CONVERSIONS_NOT_SUPPORTED)
namespace std
{
//Workaround for no implemenation of std::stoi in MinGW.
int stoi(const std::string&, std::size_t * pos = nullptr, int base = 10);
int stoi(const std::wstring&, std::size_t* pos = nullptr, int base = 10);
//Workaround for no implemenation of std::stof in MinGW.
float stof(const std::string&, std::size_t * pos = nullptr);
float stof(const std::wstring&, std::size_t* pos = nullptr);
//Workaround for no implemenation of std::stod in MinGW.
double stod(const std::string&, std::size_t * pos = nullptr);
double stod(const std::wstring&, std::size_t* pos = nullptr);
//Workaround for no implemenation of std::stold in MinGW.
long double stold(const std::string&, std::size_t * pos = nullptr);
long double stold(const std::wstring&, std::size_t* pos = nullptr);
//Workaround for no implemenation of std::stol in MinGW.
long stol(const std::string&, std::size_t* pos = nullptr, int base = 10);
long stol(const std::wstring&, std::size_t* pos = nullptr, int base = 10);
//Workaround for no implemenation of std::stoll in MinGW.
long long stoll(const std::string&, std::size_t* pos = nullptr, int base = 10);
long long stoll(const std::wstring&, std::size_t* pos = nullptr, int base = 10);
//Workaround for no implemenation of std::stoul in MinGW.
unsigned long stoul(const std::string&, std::size_t* pos = nullptr, int base = 10);
unsigned long stoul(const std::wstring&, std::size_t* pos = nullptr, int base = 10);
//Workaround for no implemenation of std::stoull in MinGW.
unsigned long long stoull(const std::string&, std::size_t* pos = nullptr, int base = 10);
unsigned long long stoull(const std::wstring&, std::size_t* pos = nullptr, int base = 10);
}
#endif //STD_NUMERIC_CONVERSIONS_NOT_SUPPORTED
#ifdef STD_TO_STRING_NOT_SUPPORTED
namespace std
{
//Workaround for no implemenation of std::to_string/std::to_wstring in MinGW.
std::string to_string(long double);
std::string to_string(double);
std::string to_string(unsigned);
std::string to_string(int);
std::string to_string(long);
std::string to_string(unsigned long);
std::string to_string(long long);
std::string to_string(unsigned long long);
std::string to_string(float);
}
#endif
#ifdef STD_TO_WSTRING_NOT_SUPPORTED
namespace std
{
std::wstring to_wstring(long double);
std::wstring to_wstring(double);
std::wstring to_wstring(unsigned);
std::wstring to_wstring(int);
std::wstring to_wstring(long);
std::wstring to_wstring(unsigned long);
std::wstring to_wstring(long long);
std::wstring to_wstring(unsigned long long);
std::wstring to_wstring(float);
}
#endif
#ifdef STD_put_time_NOT_SUPPORTED
#include <ctime>
namespace std
{
//Workaround for no implemenation of std::put_time in gcc < 5.
/* std unspecified return type */
//template< class CharT, class RTSTR >// let fail for CharT != char / wchar_t
//RTSTR put_time(const std::tm* tmb, const CharT* fmt);
//template< >
std::string put_time/*<char, std::string>*/(const std::tm* tmb, const char* fmt);
//Defined in header <ctime>
// std::size_t strftime(char* str, std::size_t count, const char* format, const std::tm* time);
//template<>
//std::wstring put_time<wchar_t, std::wstring>(const std::tm* tmb, const wchar_t* fmt);
}
#endif // STD_put_time_NOT_SUPPORTED
namespace nana
{
@ -192,45 +106,5 @@ namespace nana
#define NANA_RGB(a) (((DWORD)(a) & 0xFF)<<16) | ((DWORD)(a) & 0xFF00) | (((DWORD)(a) & 0xFF0000) >> 16 )
#ifdef STD_MAKE_UNIQUE_NOT_SUPPORTED
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3656.htm
#include <cstddef>
#include <memory>
#include <type_traits>
#include <utility>
namespace std {
template<class T> struct _Unique_if {
typedef unique_ptr<T> _Single_object;
};
template<class T> struct _Unique_if<T[]> {
typedef unique_ptr<T[]> _Unknown_bound;
};
template<class T, size_t N> struct _Unique_if<T[N]> {
typedef void _Known_bound;
};
template<class T, class... Args>
typename _Unique_if<T>::_Single_object
make_unique(Args&&... args) {
return unique_ptr<T>(new T(std::forward<Args>(args)...));
}
template<class T>
typename _Unique_if<T>::_Unknown_bound
make_unique(size_t n) {
typedef typename remove_extent<T>::type U;
return unique_ptr<T>(new U[n]());
}
template<class T, class... Args>
typename _Unique_if<T>::_Known_bound
make_unique(Args&&...) = delete;
}
#endif //STD_make_unique_NOT_SUPPORTED
#include <nana/pop_ignore_diagnostic>
#endif //NANA_DEPLOY_HPP

View File

@ -1,6 +1,6 @@
/**
* Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
* Copyright(C) 2003-2017 Jinhao(cnjinhao@hotmail.com)
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
@ -23,13 +23,13 @@ namespace filesystem_ext
{
#if defined(NANA_WINDOWS)
constexpr auto def_root = "C:";
constexpr auto def_rootstr = "C:\\";
constexpr auto def_rootname = "Local Drive(C:)";
constexpr auto const def_root = "C:";
constexpr auto const def_rootstr = "C:\\";
constexpr auto const def_rootname = "Local Drive(C:)";
#elif defined(NANA_LINUX)
constexpr auto def_root = "/";
constexpr auto def_rootstr = "/";
constexpr auto def_rootname = "Root/";
constexpr auto const def_root = "/";
constexpr auto const def_rootstr = "/";
constexpr auto const def_rootname = "Root/";
#endif
std::experimental::filesystem::path path_user(); ///< extention ?

View File

@ -647,7 +647,7 @@ namespace nana
/// usefull for both absolute and display (sorted) positions
struct index_pair
{
constexpr static size_type npos = ::nana::npos;
constexpr static const size_type npos = ::nana::npos;
size_type cat; //The pos of category
size_type item; //the pos of item in a category.

View File

@ -84,7 +84,7 @@ namespace nana
{
std::unique_ptr<Interface> create() override
{
constexpr auto Size = std::tuple_size<decltype(args_)>::value;
constexpr auto const Size = std::tuple_size<decltype(args_)>::value;
return std::unique_ptr<Interface>{ _m_new(make_pack<Size>{}) };
}

View File

@ -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(STD_put_time_NOT_SUPPORTED) )
#pragma message ( SHOW_VALUE(_enable_std_put_time) )
#pragma message ( SHOW_VALUE(STD_MAKE_UNIQUE_NOT_SUPPORTED) )
#pragma message ( SHOW_VALUE(STD_FILESYSTEM_NOT_SUPPORTED) )

View File

@ -1,7 +1,7 @@
/*
* The Deploy Implementation
* Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
* Copyright(C) 2003-2017 Jinhao(cnjinhao@hotmail.com)
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
@ -24,460 +24,6 @@
#include <nana/detail/platform_spec_selector.hpp>
#endif
//Implement workarounds for GCC/MinGW which version is below 4.8.2
#if defined(STD_NUMERIC_CONVERSIONS_NOT_SUPPORTED)
#include <sstream>
namespace std
{
int stoi(const std::string& str, std::size_t * pos, int base)
{
auto sptr = str.c_str();
char *end;
errno = 0;
auto result = std::strtol(sptr, &end, base);
if (sptr == end)
throw std::invalid_argument("invalid stoi argument");
if (errno == ERANGE)
throw std::out_of_range("stoi argument out of range");
if (pos)
*pos = (std::size_t)(end - sptr);
return ((int)result);
}
int stoi(const std::wstring& str, std::size_t* pos, int base)
{
auto sptr = str.data();
wchar_t *end;
errno = 0;
auto result = std::wcstol(sptr, &end, base);
if (sptr == end)
throw std::invalid_argument("invalid stoi argument");
if (errno == ERANGE)
throw std::out_of_range("stoi argument out of range");
if (pos)
*pos = (std::size_t)(end - sptr);
return ((int)result);
}
using ::strtof;
using ::strtold;
using ::wcstold;
using ::strtoll;
using ::wcstoll;
using ::strtoull;
using ::wcstoull;
float stof(const std::string& str, std::size_t * pos)
{
auto *ptr = str.data();
errno = 0;
char *end;
auto result = std::strtof(ptr, &end);
if (ptr == end)
throw std::invalid_argument("invalid stod argument");
if (errno == ERANGE)
throw std::out_of_range("stof argument out of range");
if (pos)
*pos = (std::size_t)(end - ptr);
return result;
}
float stof(const std::wstring& str, std::size_t* pos)
{
auto *ptr = str.data();
errno = 0;
wchar_t *end;
auto result = std::wcstof(ptr, &end);
if (ptr == end)
throw std::invalid_argument("invalid stod argument");
if (errno == ERANGE)
throw std::out_of_range("stof argument out of range");
if (pos)
*pos = (std::size_t)(end - ptr);
return result;
}
double stod(const std::string& str, std::size_t * pos)
{
auto *ptr = str.data();
errno = 0;
char *end;
auto result = std::strtod(ptr, &end);
if (ptr == end)
throw std::invalid_argument("invalid stod argument");
if (errno == ERANGE)
throw std::out_of_range("stod argument out of range");
if (pos)
*pos = (std::size_t)(end - ptr);
return result;
}
double stod(const std::wstring& str, std::size_t* pos)
{
auto *ptr = str.data();
errno = 0;
wchar_t *end;
auto result = std::wcstod(ptr, &end);
if (ptr == end)
throw std::invalid_argument("invalid stod argument");
if (errno == ERANGE)
throw std::out_of_range("stod argument out of range");
if (pos)
*pos = (std::size_t)(end - ptr);
return result;
}
long double stold(const std::string& str, std::size_t * pos)
{
auto *ptr = str.data();
errno = 0;
char *end;
auto result = std::strtold(ptr, &end);
if (ptr == end)
throw std::invalid_argument("invalid stod argument");
if (errno == ERANGE)
throw std::out_of_range("stold argument out of range");
if (pos)
*pos = (std::size_t)(end - ptr);
return result;
}
long double stold(const std::wstring& str, std::size_t* pos)
{
auto *ptr = str.data();
errno = 0;
wchar_t *end;
auto result = std::wcstold(ptr, &end);
if (ptr == end)
throw std::invalid_argument("invalid stod argument");
if (errno == ERANGE)
throw std::out_of_range("stold argument out of range");
if (pos)
*pos = (std::size_t)(end - ptr);
return result;
}
long stol(const std::string& str, std::size_t* pos, int base)
{
auto *ptr = str.data();
errno = 0;
char *end;
auto result = std::strtol(ptr, &end, base);
if (ptr == end)
throw std::invalid_argument("invalid stod argument");
if (errno == ERANGE)
throw std::out_of_range("stol argument out of range");
if (pos)
*pos = (std::size_t)(end - ptr);
return result;
}
long stol(const std::wstring& str, std::size_t* pos, int base)
{
auto *ptr = str.data();
errno = 0;
wchar_t *end;
auto result = std::wcstol(ptr, &end, base);
if (ptr == end)
throw std::invalid_argument("invalid stod argument");
if (errno == ERANGE)
throw std::out_of_range("stol argument out of range");
if (pos)
*pos = (std::size_t)(end - ptr);
return result;
}
//Workaround for no implemenation of std::stoll in MinGW.
long long stoll(const std::string& str, std::size_t* pos, int base)
{
auto *ptr = str.data();
errno = 0;
char* end;
auto result = std::strtoll(ptr, &end, base);
if (ptr == end)
throw std::invalid_argument("invalid stod argument");
if (errno == ERANGE)
throw std::out_of_range("stoll argument out of range");
if (pos)
*pos = (std::size_t)(end - ptr);
return result;
}
long long stoll(const std::wstring& str, std::size_t* pos, int base)
{
auto *ptr = str.data();
errno = 0;
wchar_t* end;
auto result = std::wcstoll(ptr, &end, base);
if (ptr == end)
throw std::invalid_argument("invalid stod argument");
if (errno == ERANGE)
throw std::out_of_range("stoll argument out of range");
if (pos)
*pos = (std::size_t)(end - ptr);
return result;
}
unsigned long long stoull(const std::string& str, std::size_t* pos, int base)
{
auto *ptr = str.data();
errno = 0;
char* end;
auto result = std::strtoull(ptr, &end, base);
if (ptr == end)
throw std::invalid_argument("invalid stod argument");
if (errno == ERANGE)
throw std::out_of_range("stoull argument out of range");
if (pos)
*pos = (std::size_t)(end - ptr);
return result;
}
unsigned long long stoull(const std::wstring& str, std::size_t* pos, int base)
{
auto *ptr = str.data();
errno = 0;
wchar_t* end;
auto result = std::wcstoull(ptr, &end, base);
if (ptr == end)
throw std::invalid_argument("invalid stod argument");
if (errno == ERANGE)
throw std::out_of_range("stoull argument out of range");
if (pos)
*pos = (std::size_t)(end - ptr);
return result;
}
//Workaround for no implemenation of std::stoul in MinGW.
unsigned long stoul(const std::string& str, std::size_t* pos, int base)
{
auto *ptr = str.data();
errno = 0;
char* end;
auto result = std::strtoul(ptr, &end, base);
if (ptr == end)
throw std::invalid_argument("invalid stod argument");
if (errno == ERANGE)
throw std::out_of_range("stoul argument out of range");
if (pos)
*pos = (std::size_t)(end - ptr);
return result;
}
unsigned long stoul(const std::wstring& str, std::size_t* pos, int base)
{
auto *ptr = str.data();
errno = 0;
wchar_t* end;
auto result = std::wcstoul(ptr, &end, base);
if (ptr == end)
throw std::invalid_argument("invalid stod argument");
if (errno == ERANGE)
throw std::out_of_range("stoul argument out of range");
if (pos)
*pos = (std::size_t)(end - ptr);
return result;
}
}//end namespace std
#endif //STD_NUMERIC_CONVERSIONS_NOT_SUPPORTED
#ifdef STD_TO_STRING_NOT_SUPPORTED
#include <sstream>
namespace std
{
std::string to_string(double v)
{
std::stringstream ss;
ss << v;
return ss.str();
}
std::string to_string(long double v)
{
std::stringstream ss;
ss << v;
return ss.str();
}
std::string to_string(unsigned v)
{
std::stringstream ss;
ss << v;
return ss.str();
}
std::string to_string(int v)
{
std::stringstream ss;
ss << v;
return ss.str();
}
std::string to_string(long v)
{
std::stringstream ss;
ss << v;
return ss.str();
}
std::string to_string(unsigned long v)
{
std::stringstream ss;
ss << v;
return ss.str();
}
std::string to_string(long long v)
{
std::stringstream ss;
ss << v;
return ss.str();
}
std::string to_string(unsigned long long v)
{
std::stringstream ss;
ss << v;
return ss.str();
}
std::string to_string(float v)
{
std::stringstream ss;
ss << v;
return ss.str();
}
}
#endif // STD_TO_STRING_NOT_SUPPORTED
#ifdef STD_TO_WSTRING_NOT_SUPPORTED
#include <sstream>
namespace std
{
std::wstring to_wstring(double v)
{
std::wstringstream ss;
ss << v;
return ss.str();
}
std::wstring to_wstring(long double v)
{
std::wstringstream ss;
ss << v;
return ss.str();
}
std::wstring to_wstring(unsigned v)
{
std::wstringstream ss;
ss << v;
return ss.str();
}
std::wstring to_wstring(int v)
{
std::wstringstream ss;
ss << v;
return ss.str();
}
std::wstring to_wstring(long v)
{
std::wstringstream ss;
ss << v;
return ss.str();
}
std::wstring to_wstring(unsigned long v)
{
std::wstringstream ss;
ss << v;
return ss.str();
}
std::wstring to_wstring(long long v)
{
std::wstringstream ss;
ss << v;
return ss.str();
}
std::wstring to_wstring(unsigned long long v)
{
std::wstringstream ss;
ss << v;
return ss.str();
}
std::wstring to_wstring(float v)
{
std::wstringstream ss;
ss << v;
return ss.str();
}
}
#endif
//#ifdef STD_put_time_NOT_SUPPORTED
#include <ctime>
#include <cwchar>
namespace std
{
//Workaround for no implemenation of std::put_time in gcc < 5.
/* std unspecified return type */
//template< class CharT, class RTSTR >// let fail for CharT != char / wchar_t
//RTSTR put_time(const std::tm* tmb, const CharT* fmt);
//template< >
std::string put_time/*<char, std::string>*/(const std::tm* tmb, const char* fmt)
{
std::size_t sz = 200;
std::string str(sz, '\0');
sz = std::strftime(&str[0], str.size() - 1, fmt, tmb);
str.resize(sz);
return str;
}
//Defined in header <ctime>
// std::size_t strftime(char* str, std::size_t count, const char* format, const std::tm* time);
//template<>
//std::wstring put_time<wchar_t, std::wstring>(const std::tm* tmb, const wchar_t* fmt)
//{
// unsigned sz = 200;
// std::wstring str(sz, L'\0');
// sz = std::wcsftime(&str[0], str.size() - 1, fmt, tmb);
// str.resize(sz);
// return str;
//}
// http://en.cppreference.com/w/cpp/chrono/c/wcsftime
// Defined in header <cwchar>
// std::size_t wcsftime(wchar_t* str, std::size_t count, const wchar_t* format, const std::tm* time);
// Converts the date and time information from a given calendar time time to a null - terminated
// wide character string str according to format string format.Up to count bytes are written.
// Parameters
// str - pointer to the first element of the wchar_t array for output
// count - maximum number of wide characters to write
// format - pointer to a null - terminated wide character string specifying the format of conversion.
}
//#endif // STD_put_time_NOT_SUPPORTED
#include <iostream>
@ -523,12 +69,12 @@ namespace nana
# endif
#endif
void utf8_Error::emit()
{
if (use_throw)
throw utf8_Error(*this);
std::cerr << what();
}
void utf8_Error::emit()
{
if (use_throw)
throw utf8_Error(*this);
std::cerr << what();
}
//bool utf8_Error::use_throw{true};
bool utf8_Error::use_throw{ false };
@ -536,25 +82,18 @@ namespace nana
void throw_not_utf8(const std::string& text)
{
if (!is_utf8(text.c_str(), text.length()))
return utf8_Error(std::string("\nThe text is not encoded in UTF8: ") + text).emit();
throw_not_utf8(text.c_str(), text.size());
}
void throw_not_utf8(const char* text)
{
throw_not_utf8(text, std::strlen(text));
}
void throw_not_utf8(const char* text, std::size_t len)
{
if (!is_utf8(text, len))
return utf8_Error(std::string("\nThe text is not encoded in UTF8: ") + std::string(text, len) ).emit();
//throw std::invalid_argument("The text is not encoded in UTF8");
}
void throw_not_utf8(const char* text)
{
if (!is_utf8(text, std::strlen(text)))
return utf8_Error(std::string("\nThe text is not encoded in UTF8: ") + text).emit();
//throw std::invalid_argument("The text is not encoded in UTF8");
}
std::string recode_to_utf8(std::string no_utf8)
@ -587,8 +126,6 @@ namespace nana
return false;
}
const std::string& to_utf8(const std::string& str)
{
return str;