mirror of
https://github.com/ETLCPP/etl.git
synced 2026-11-09 22:59:47 +08:00
Added non-const string pointer overload
This commit is contained in:
parent
b5e5c5ecca
commit
1b7a59be92
@ -561,14 +561,14 @@ namespace etl
|
||||
-> array<etl::enable_if_t<(etl::is_same_v<T, Ts> && ...), T>, 1U + sizeof...(Ts)>;
|
||||
#endif
|
||||
|
||||
#if ETL_CPP11_SUPPORTED
|
||||
template <typename... T>
|
||||
constexpr auto make_array(T&&... t)
|
||||
-> etl::array<std::common_type_t<T...>, sizeof...(T)>
|
||||
{
|
||||
return { { etl::forward<T>(t)... } };
|
||||
}
|
||||
#endif
|
||||
//#if ETL_CPP11_SUPPORTED
|
||||
// template <typename... T>
|
||||
// constexpr auto make_array(T&&... t)
|
||||
// -> etl::array<std::common_type_t<T...>, sizeof...(T)>
|
||||
// {
|
||||
// return { { etl::forward<T>(t)... } };
|
||||
// }
|
||||
//#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Overloaded swap for etl::array<T, SIZE>
|
||||
|
||||
@ -46,6 +46,7 @@ namespace etl
|
||||
typedef TFormat format_spec_type;
|
||||
typedef TIString istring_type;
|
||||
typedef typename TIString::value_type value_type;
|
||||
typedef typename TIString::pointer pointer;
|
||||
typedef typename TIString::const_pointer const_pointer;
|
||||
|
||||
//*************************************************************************
|
||||
@ -218,7 +219,17 @@ namespace etl
|
||||
}
|
||||
|
||||
//*********************************
|
||||
/// From a const pointer to a string
|
||||
/// From a character pointer to a string
|
||||
//*********************************
|
||||
friend basic_string_stream& operator <<(basic_string_stream& ss, pointer p)
|
||||
{
|
||||
TStringView view(p);
|
||||
ss << view;
|
||||
return ss;
|
||||
}
|
||||
|
||||
//*********************************
|
||||
/// From a const character pointer to a string
|
||||
//*********************************
|
||||
friend basic_string_stream& operator <<(basic_string_stream& ss, const_pointer p)
|
||||
{
|
||||
|
||||
@ -646,12 +646,12 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_make_array)
|
||||
{
|
||||
auto data = etl::make_array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
|
||||
//TEST(test_make_array)
|
||||
//{
|
||||
// auto data = etl::make_array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
|
||||
|
||||
CHECK_EQUAL(5, data[5]);
|
||||
}
|
||||
// CHECK_EQUAL(5, data[5]);
|
||||
//}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@ -80,7 +80,7 @@ namespace
|
||||
SUITE(test_string_stream)
|
||||
{
|
||||
//*************************************************************************
|
||||
TEST(test_default_format)
|
||||
TEST(test_default_format_from_const_char)
|
||||
{
|
||||
String str;
|
||||
|
||||
@ -95,6 +95,22 @@ namespace
|
||||
CHECK_EQUAL(String(STR("Hello World 123")), result);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_default_format_from_char)
|
||||
{
|
||||
String str;
|
||||
|
||||
Stream ss(str);
|
||||
|
||||
int value = 123;
|
||||
String hello(STR("Hello"));
|
||||
ss << hello << const_cast<char*>(STR(" World ")) << value;
|
||||
|
||||
String result = ss.str();
|
||||
|
||||
CHECK_EQUAL(String(STR("Hello World 123")), result);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_custom_format)
|
||||
{
|
||||
|
||||
@ -80,7 +80,7 @@ namespace
|
||||
SUITE(test_string_stream)
|
||||
{
|
||||
//*************************************************************************
|
||||
TEST(test_default_format)
|
||||
TEST(test_default_format_from_const_char)
|
||||
{
|
||||
String str;
|
||||
|
||||
@ -95,6 +95,22 @@ namespace
|
||||
CHECK_EQUAL(String(STR("Hello World 123")), result);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_default_format_from_char)
|
||||
{
|
||||
String str;
|
||||
|
||||
Stream ss(str);
|
||||
|
||||
int value = 123;
|
||||
String hello(STR("Hello"));
|
||||
ss << hello << const_cast<char16_t*>(STR(" World ")) << value;
|
||||
|
||||
String result = ss.str();
|
||||
|
||||
CHECK_EQUAL(String(STR("Hello World 123")), result);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_custom_format)
|
||||
{
|
||||
|
||||
@ -80,7 +80,7 @@ namespace
|
||||
SUITE(test_string_stream)
|
||||
{
|
||||
//*************************************************************************
|
||||
TEST(test_default_format)
|
||||
TEST(test_default_format_from_const_char)
|
||||
{
|
||||
String str;
|
||||
|
||||
@ -95,6 +95,22 @@ namespace
|
||||
CHECK_EQUAL(String(STR("Hello World 123")), result);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_default_format_from_char)
|
||||
{
|
||||
String str;
|
||||
|
||||
Stream ss(str);
|
||||
|
||||
int value = 123;
|
||||
String hello(STR("Hello"));
|
||||
ss << hello << const_cast<char32_t*>(STR(" World ")) << value;
|
||||
|
||||
String result = ss.str();
|
||||
|
||||
CHECK_EQUAL(String(STR("Hello World 123")), result);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_custom_format)
|
||||
{
|
||||
|
||||
@ -81,7 +81,7 @@ namespace
|
||||
SUITE(test_string_stream)
|
||||
{
|
||||
//*************************************************************************
|
||||
TEST(test_default_format)
|
||||
TEST(test_default_format_from_const_char)
|
||||
{
|
||||
String str;
|
||||
|
||||
@ -96,6 +96,22 @@ namespace
|
||||
CHECK_EQUAL(String(STR("Hello World 123")), result);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_default_format_from_char)
|
||||
{
|
||||
String str;
|
||||
|
||||
Stream ss(str);
|
||||
|
||||
int value = 123;
|
||||
String hello(STR("Hello"));
|
||||
ss << hello << const_cast<wchar_t*>(STR(" World ")) << value;
|
||||
|
||||
String result = ss.str();
|
||||
|
||||
CHECK_EQUAL(String(STR("Hello World 123")), result);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_custom_format)
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user