Added definitions for large character types if not already supported.

Fixed compile error.
This commit is contained in:
John Wellbelove 2016-06-18 07:10:12 +01:00
parent b9e20437d8
commit 21ecdd5055

View File

@ -31,8 +31,11 @@ SOFTWARE.
#ifndef __ETL_CHAR_TRAITS__
#define __ETL_CHAR_TRAITS__
#include <algorithm>
#include "platform.h"
#include "stdint.h"
#include "algorithms.h"
#include "algorithm.h"
//*****************************************************************************
///\defgroup char_traits char_traits
@ -40,6 +43,12 @@ SOFTWARE.
///\ingroup string
//*****************************************************************************
// Define the large character types if necessary.
#ifdef NO_LARGE_CHAR_SUPPORT
typedef int16_t char16_t;
typedef int32_t char32_t;
#endif
namespace etl
{
template<typename T> struct char_traits_types;
@ -81,11 +90,17 @@ namespace etl
};
//***************************************************************************
/// Specialisation for char.
/// Character traits for any character type.
//***************************************************************************
template<typename T>
struct char_traits : public char_traits_types<T>
{
typedef typename char_traits_types<T>::char_type char_type;
typedef typename char_traits_types<T>::int_type int_type;
typedef typename char_traits_types<T>::off_type off_type;
typedef typename char_traits_types<T>::pos_type pos_type;
typedef typename char_traits_types<T>::state_type state_type;
//*************************************************************************
static bool eq(char_type a, char_type b)
{
@ -99,7 +114,7 @@ namespace etl
}
//*************************************************************************
static size_t length(const char* str)
static size_t length(const char_type* str)
{
size_t count = 0;
@ -134,7 +149,7 @@ namespace etl
//*************************************************************************
static char_type* move(char_type* dest, const char_type* src, size_t count)
{
if ((dest < src) || (dest > (src + count))
if ((dest < src) || (dest > (src + count)))
{
etl::copy_n(src, src + count, dest);
}