mirror of
https://github.com/ETLCPP/etl.git
synced 2026-04-30 19:09:10 +08:00
Fixed C++ standard compatibility issues
This commit is contained in:
parent
6559615242
commit
bc44bf7a46
@ -396,6 +396,28 @@ namespace etl
|
||||
this->resize(count, c);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// From string_view.
|
||||
///\param view The string_view.
|
||||
//*************************************************************************
|
||||
explicit string_ext(const etl::string_view& view, value_type* buffer, size_type buffer_size)
|
||||
: istring(buffer, buffer_size - 1U)
|
||||
{
|
||||
this->assign(view.begin(), view.end());
|
||||
}
|
||||
|
||||
#if ETL_USING_STL && ETL_USING_CPP17
|
||||
//*************************************************************************
|
||||
/// From string_view.
|
||||
///\param view The string_view.
|
||||
//*************************************************************************
|
||||
explicit string_ext(const std::string_view& view, value_type* buffer, size_type buffer_size)
|
||||
: istring(buffer, buffer_size - 1U)
|
||||
{
|
||||
this->assign(view.begin(), view.end());
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Constructor, from an iterator range.
|
||||
///\tparam TIterator The iterator type.
|
||||
@ -420,16 +442,6 @@ namespace etl
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// From string_view.
|
||||
///\param view The string_view.
|
||||
//*************************************************************************
|
||||
explicit string_ext(const etl::string_view& view, value_type* buffer, size_type buffer_size)
|
||||
: istring(buffer, buffer_size - 1U)
|
||||
{
|
||||
this->assign(view.begin(), view.end());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Assignment operator.
|
||||
//*************************************************************************
|
||||
@ -443,7 +455,6 @@ namespace etl
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
//*************************************************************************
|
||||
/// Assignment operator.
|
||||
//*************************************************************************
|
||||
@ -467,6 +478,28 @@ namespace etl
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Assignment operator.
|
||||
//*************************************************************************
|
||||
string_ext& operator = (const etl::string_view& view)
|
||||
{
|
||||
this->assign(view);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if ETL_USING_STL && ETL_USING_CPP17
|
||||
//*************************************************************************
|
||||
/// Assignment operator.
|
||||
//*************************************************************************
|
||||
string_ext& operator = (const std::string_view& view)
|
||||
{
|
||||
this->assign(view);
|
||||
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Fix the internal pointers after a low level memory copy.
|
||||
//*************************************************************************
|
||||
|
||||
@ -400,8 +400,8 @@ namespace etl
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// From u16string_view.
|
||||
///\param view The u16string_view.
|
||||
/// From string_view.
|
||||
///\param view The string_view.
|
||||
//*************************************************************************
|
||||
explicit u16string_ext(const etl::u16string_view& view, value_type* buffer, size_type buffer_size)
|
||||
: iu16string(buffer, buffer_size - 1U)
|
||||
@ -409,6 +409,18 @@ namespace etl
|
||||
this->assign(view.begin(), view.end());
|
||||
}
|
||||
|
||||
#if ETL_USING_STL && ETL_USING_CPP17
|
||||
//*************************************************************************
|
||||
/// From string_view.
|
||||
///\param view The string_view.
|
||||
//*************************************************************************
|
||||
explicit u16string_ext(const std::u16string_view& view, value_type* buffer, size_type buffer_size)
|
||||
: iu16string(buffer, buffer_size - 1U)
|
||||
{
|
||||
this->assign(view.begin(), view.end());
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Assignment operator.
|
||||
//*************************************************************************
|
||||
@ -422,7 +434,6 @@ namespace etl
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
//*************************************************************************
|
||||
/// Assignment operator.
|
||||
//*************************************************************************
|
||||
@ -446,6 +457,28 @@ namespace etl
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Assignment operator.
|
||||
//*************************************************************************
|
||||
u16string_ext& operator = (const etl::u16string_view& view)
|
||||
{
|
||||
this->assign(view);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if ETL_USING_STL && ETL_USING_CPP17
|
||||
//*************************************************************************
|
||||
/// Assignment operator.
|
||||
//*************************************************************************
|
||||
u16string_ext& operator = (const std::u16string_view& view)
|
||||
{
|
||||
this->assign(view);
|
||||
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Fix the internal pointers after a low level memory copy.
|
||||
//*************************************************************************
|
||||
|
||||
@ -400,8 +400,8 @@ namespace etl
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// From u32string_view.
|
||||
///\param view The u32string_view.
|
||||
/// From string_view.
|
||||
///\param view The string_view.
|
||||
//*************************************************************************
|
||||
explicit u32string_ext(const etl::u32string_view& view, value_type* buffer, size_type buffer_size)
|
||||
: iu32string(buffer, buffer_size - 1U)
|
||||
@ -409,6 +409,18 @@ namespace etl
|
||||
this->assign(view.begin(), view.end());
|
||||
}
|
||||
|
||||
#if ETL_USING_STL && ETL_USING_CPP17
|
||||
//*************************************************************************
|
||||
/// From string_view.
|
||||
///\param view The string_view.
|
||||
//*************************************************************************
|
||||
explicit u32string_ext(const std::u32string_view& view, value_type* buffer, size_type buffer_size)
|
||||
: iu32string(buffer, buffer_size - 1U)
|
||||
{
|
||||
this->assign(view.begin(), view.end());
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Assignment operator.
|
||||
//*************************************************************************
|
||||
@ -422,7 +434,6 @@ namespace etl
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
//*************************************************************************
|
||||
/// Assignment operator.
|
||||
//*************************************************************************
|
||||
@ -446,6 +457,28 @@ namespace etl
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Assignment operator.
|
||||
//*************************************************************************
|
||||
u32string_ext& operator = (const etl::u32string_view& view)
|
||||
{
|
||||
this->assign(view);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if ETL_USING_STL && ETL_USING_CPP17
|
||||
//*************************************************************************
|
||||
/// Assignment operator.
|
||||
//*************************************************************************
|
||||
u32string_ext& operator = (const std::u32string_view& view)
|
||||
{
|
||||
this->assign(view);
|
||||
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Fix the internal pointers after a low level memory copy.
|
||||
//*************************************************************************
|
||||
|
||||
@ -186,7 +186,7 @@ namespace etl
|
||||
this->assign(view.begin(), view.end());
|
||||
}
|
||||
|
||||
#if ETL_USING_STL && ETL_USING_CPP17
|
||||
#if ETL_USING_STL && ETL_USING_CPP20
|
||||
//*************************************************************************
|
||||
/// From string_view.
|
||||
///\param view The string_view.
|
||||
@ -266,7 +266,7 @@ namespace etl
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if ETL_USING_STL && ETL_USING_CPP17
|
||||
#if ETL_USING_STL && ETL_USING_CPP20
|
||||
//*************************************************************************
|
||||
/// Assignment operator.
|
||||
//*************************************************************************
|
||||
@ -430,6 +430,18 @@ namespace etl
|
||||
this->assign(view.begin(), view.end());
|
||||
}
|
||||
|
||||
#if ETL_USING_STL && ETL_USING_CPP20
|
||||
//*************************************************************************
|
||||
/// From string_view.
|
||||
///\param view The string_view.
|
||||
//*************************************************************************
|
||||
explicit u8string_ext(const std::u8string_view& view, value_type* buffer, size_type buffer_size)
|
||||
: iu8string(buffer, buffer_size - 1U)
|
||||
{
|
||||
this->assign(view.begin(), view.end());
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Assignment operator.
|
||||
//*************************************************************************
|
||||
@ -443,7 +455,6 @@ namespace etl
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
//*************************************************************************
|
||||
/// Assignment operator.
|
||||
//*************************************************************************
|
||||
@ -467,6 +478,28 @@ namespace etl
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Assignment operator.
|
||||
//*************************************************************************
|
||||
u8string_ext& operator = (const etl::u8string_view& view)
|
||||
{
|
||||
this->assign(view);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if ETL_USING_STL && ETL_USING_CPP20
|
||||
//*************************************************************************
|
||||
/// Assignment operator.
|
||||
//*************************************************************************
|
||||
u8string_ext& operator = (const std::u8string_view& view)
|
||||
{
|
||||
this->assign(view);
|
||||
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Fix the internal pointers after a low level memory copy.
|
||||
//*************************************************************************
|
||||
|
||||
@ -400,8 +400,8 @@ namespace etl
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// From wstring_view.
|
||||
///\param view The wstring_view.
|
||||
/// From string_view.
|
||||
///\param view The string_view.
|
||||
//*************************************************************************
|
||||
explicit wstring_ext(const etl::wstring_view& view, value_type* buffer, size_type buffer_size)
|
||||
: iwstring(buffer, buffer_size - 1U)
|
||||
@ -409,6 +409,18 @@ namespace etl
|
||||
this->assign(view.begin(), view.end());
|
||||
}
|
||||
|
||||
#if ETL_USING_STL && ETL_USING_CPP17
|
||||
//*************************************************************************
|
||||
/// From string_view.
|
||||
///\param view The string_view.
|
||||
//*************************************************************************
|
||||
explicit wstring_ext(const std::wstring_view& view, value_type* buffer, size_type buffer_size)
|
||||
: iwstring(buffer, buffer_size - 1U)
|
||||
{
|
||||
this->assign(view.begin(), view.end());
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Assignment operator.
|
||||
//*************************************************************************
|
||||
@ -422,7 +434,6 @@ namespace etl
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
//*************************************************************************
|
||||
/// Assignment operator.
|
||||
//*************************************************************************
|
||||
@ -446,6 +457,28 @@ namespace etl
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Assignment operator.
|
||||
//*************************************************************************
|
||||
wstring_ext& operator = (const etl::wstring_view& view)
|
||||
{
|
||||
this->assign(view);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if ETL_USING_STL && ETL_USING_CPP17
|
||||
//*************************************************************************
|
||||
/// Assignment operator.
|
||||
//*************************************************************************
|
||||
wstring_ext& operator = (const std::wstring_view& view)
|
||||
{
|
||||
this->assign(view);
|
||||
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Fix the internal pointers after a low level memory copy.
|
||||
//*************************************************************************
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -31,6 +31,7 @@ SOFTWARE.
|
||||
#include "etl/string_view.h"
|
||||
#include "etl/string.h"
|
||||
#include "etl/wstring.h"
|
||||
#include "etl/u8string.h"
|
||||
#include "etl/u16string.h"
|
||||
#include "etl/u32string.h"
|
||||
#include "etl/hash.h"
|
||||
@ -45,12 +46,18 @@ namespace
|
||||
{
|
||||
using View = etl::string_view;
|
||||
using WView = etl::wstring_view;
|
||||
#if ETL_USING_CPP20
|
||||
using U8View = etl::u8string_view;
|
||||
#endif
|
||||
using U16View = etl::u16string_view;
|
||||
using U32View = etl::u32string_view;
|
||||
|
||||
etl::string<11> etltext = "Hello World";
|
||||
std::string text = "Hello World";
|
||||
std::wstring wtext = L"Hello World";
|
||||
#if ETL_USING_CPP20
|
||||
std::u8string u8text = u8"Hello World";
|
||||
#endif
|
||||
std::u16string u16text = u"Hello World";
|
||||
std::u32string u32text = U"Hello World";
|
||||
std::string text_smaller = "Hello Worlc";
|
||||
@ -166,7 +173,7 @@ namespace
|
||||
//*************************************************************************
|
||||
TEST(test_constructor_from_std_string_view)
|
||||
{
|
||||
std::string_view stdview(etltext.begin(), etltext.end());
|
||||
std::string_view stdview(text.data(), text.size());
|
||||
|
||||
View view(stdview);
|
||||
|
||||
@ -182,7 +189,7 @@ namespace
|
||||
//*************************************************************************
|
||||
TEST(test_constructor_from_std_wstring_view)
|
||||
{
|
||||
std::wstring_view stdview(wtext.begin(), wtext.end());
|
||||
std::wstring_view stdview(wtext.data(), wtext.size());
|
||||
|
||||
WView view(stdview);
|
||||
|
||||
@ -194,11 +201,27 @@ namespace
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ETL_USING_STL && ETL_USING_CPP20
|
||||
//*************************************************************************
|
||||
TEST(test_constructor_from_std_u8string_view)
|
||||
{
|
||||
std::u8string_view stdview(u8text.begin(), u8text.end());
|
||||
|
||||
U8View view(stdview);
|
||||
|
||||
CHECK(stdview.size() == view.size());
|
||||
CHECK(stdview.size() == view.max_size());
|
||||
|
||||
bool isEqual = std::equal(view.begin(), view.end(), stdview.begin());
|
||||
CHECK(isEqual);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ETL_USING_STL && ETL_USING_CPP17
|
||||
//*************************************************************************
|
||||
TEST(test_constructor_from_std_u16string_view)
|
||||
{
|
||||
std::u16string_view stdview(u16text.begin(), u16text.end());
|
||||
std::u16string_view stdview(u16text.data(), u16text.size());
|
||||
|
||||
U16View view(stdview);
|
||||
|
||||
@ -214,7 +237,7 @@ namespace
|
||||
//*************************************************************************
|
||||
TEST(test_constructor_from_std_u32string_view)
|
||||
{
|
||||
std::u32string_view stdview(u32text.begin(), u32text.end());
|
||||
std::u32string_view stdview(u32text.data(), u32text.size());
|
||||
|
||||
U32View view(stdview);
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user