Added and fixed noexcept attributes

Added ETL_NOEXCEPT_FROM to set noexcept attributes based on an object or function.
This commit is contained in:
John Wellbelove 2025-09-17 20:44:52 +01:00
parent f9cf20d79a
commit 294720937f
8 changed files with 144 additions and 142 deletions

View File

@ -380,7 +380,7 @@ namespace etl
/// Swaps the contents of this array and another.
///\param other A reference to the other array.
//*************************************************************************
ETL_CONSTEXPR14 void swap(array& other) ETL_NOEXCEPT
ETL_CONSTEXPR14 void swap(array& other) ETL_NOEXCEPT_FROM(ETL_OR_STD::swap(etl::declval<T&>(), etl::declval<T&>()))
{
using ETL_OR_STD::swap; // Allow ADL

View File

@ -123,7 +123,7 @@ namespace etl
//*************************************************************************
/// Default constructor.
//*************************************************************************
ETL_CONSTEXPR array_view()
ETL_CONSTEXPR array_view() ETL_NOEXCEPT
: mbegin(ETL_NULLPTR),
mend(ETL_NULLPTR)
{
@ -238,7 +238,7 @@ namespace etl
/// Construct from iterators
//*************************************************************************
template <typename TIterator>
ETL_CONSTEXPR array_view(const TIterator begin_, const TIterator end_)
ETL_CONSTEXPR array_view(const TIterator begin_, const TIterator end_) ETL_NOEXCEPT
: mbegin(etl::to_address(begin_)),
mend(etl::to_address(begin_) + etl::distance(begin_, end_))
{
@ -249,7 +249,7 @@ namespace etl
//*************************************************************************
template <typename TIterator,
typename TSize>
ETL_CONSTEXPR array_view(const TIterator begin_, const TSize size_)
ETL_CONSTEXPR array_view(const TIterator begin_, const TSize size_) ETL_NOEXCEPT
: mbegin(etl::to_address(begin_)),
mend(etl::to_address(begin_) + size_)
{
@ -259,7 +259,7 @@ namespace etl
/// Construct from C array
//*************************************************************************
template<size_t Array_Size>
ETL_CONSTEXPR array_view(T(&begin_)[Array_Size])
ETL_CONSTEXPR array_view(T(&begin_)[Array_Size]) ETL_NOEXCEPT
: mbegin(begin_),
mend(begin_ + Array_Size)
{
@ -268,7 +268,7 @@ namespace etl
//*************************************************************************
/// Copy constructor
//*************************************************************************
ETL_CONSTEXPR array_view(const array_view& other)
ETL_CONSTEXPR array_view(const array_view& other) ETL_NOEXCEPT
: mbegin(other.mbegin),
mend(other.mend)
{
@ -309,7 +309,7 @@ namespace etl
//*************************************************************************
/// Returns a pointer to the first element of the internal storage.
//*************************************************************************
pointer data()
pointer data() ETL_NOEXCEPT
{
return mbegin;
}
@ -317,7 +317,7 @@ namespace etl
//*************************************************************************
/// Returns a const pointer to the first element of the internal storage.
//*************************************************************************
const_pointer data() const
const_pointer data() const ETL_NOEXCEPT
{
return mbegin;
}
@ -325,7 +325,7 @@ namespace etl
//*************************************************************************
/// Returns an iterator to the beginning of the array.
//*************************************************************************
iterator begin()
iterator begin() ETL_NOEXCEPT
{
return mbegin;
}
@ -333,7 +333,7 @@ namespace etl
//*************************************************************************
/// Returns a const iterator to the beginning of the array.
//*************************************************************************
const_iterator begin() const
const_iterator begin() const ETL_NOEXCEPT
{
return mbegin;
}
@ -341,7 +341,7 @@ namespace etl
//*************************************************************************
/// Returns a const iterator to the beginning of the array.
//*************************************************************************
const_iterator cbegin() const
const_iterator cbegin() const ETL_NOEXCEPT
{
return mbegin;
}
@ -349,7 +349,7 @@ namespace etl
//*************************************************************************
/// Returns an iterator to the end of the array.
//*************************************************************************
iterator end()
iterator end() ETL_NOEXCEPT
{
return mend;
}
@ -357,7 +357,7 @@ namespace etl
//*************************************************************************
/// Returns a const iterator to the end of the array.
//*************************************************************************
const_iterator end() const
const_iterator end() const ETL_NOEXCEPT
{
return mend;
}
@ -365,7 +365,7 @@ namespace etl
//*************************************************************************
// Returns a const iterator to the end of the array.
//*************************************************************************
const_iterator cend() const
const_iterator cend() const ETL_NOEXCEPT
{
return mend;
}
@ -373,7 +373,7 @@ namespace etl
//*************************************************************************
// Returns an reverse iterator to the reverse beginning of the array.
//*************************************************************************
reverse_iterator rbegin()
reverse_iterator rbegin() ETL_NOEXCEPT
{
return reverse_iterator(mend);
}
@ -381,7 +381,7 @@ namespace etl
//*************************************************************************
/// Returns a const reverse iterator to the reverse beginning of the array.
//*************************************************************************
const_reverse_iterator rbegin() const
const_reverse_iterator rbegin() const ETL_NOEXCEPT
{
return const_reverse_iterator(mend);
}
@ -389,7 +389,7 @@ namespace etl
//*************************************************************************
/// Returns a const reverse iterator to the reverse beginning of the array.
//*************************************************************************
const_reverse_iterator crbegin() const
const_reverse_iterator crbegin() const ETL_NOEXCEPT
{
return const_reverse_iterator(mend);
}
@ -397,7 +397,7 @@ namespace etl
//*************************************************************************
/// Returns a reverse iterator to the end of the array.
//*************************************************************************
reverse_iterator rend()
reverse_iterator rend() ETL_NOEXCEPT
{
return reverse_iterator(mbegin);
}
@ -405,7 +405,7 @@ namespace etl
//*************************************************************************
/// Returns a const reverse iterator to the end of the array.
//*************************************************************************
const_reverse_iterator rend() const
const_reverse_iterator rend() const ETL_NOEXCEPT
{
return const_reverse_iterator(mbegin);
}
@ -413,7 +413,7 @@ namespace etl
//*************************************************************************
/// Returns a const reverse iterator to the end of the array.
//*************************************************************************
const_reverse_iterator crend() const
const_reverse_iterator crend() const ETL_NOEXCEPT
{
return const_reverse_iterator(mbegin);
}
@ -421,7 +421,7 @@ namespace etl
//*************************************************************************
/// Returns <b>true</b> if the array size is zero.
//*************************************************************************
ETL_CONSTEXPR bool empty() const
ETL_CONSTEXPR bool empty() const ETL_NOEXCEPT
{
return (mbegin == mend);
}
@ -429,7 +429,7 @@ namespace etl
//*************************************************************************
/// Returns the size of the array.
//*************************************************************************
ETL_CONSTEXPR size_t size() const
ETL_CONSTEXPR size_t size() const ETL_NOEXCEPT
{
return static_cast<size_t>(mend - mbegin);
}
@ -437,7 +437,7 @@ namespace etl
//*************************************************************************
/// Returns the maximum possible size of the array.
//*************************************************************************
ETL_CONSTEXPR size_t max_size() const
ETL_CONSTEXPR size_t max_size() const ETL_NOEXCEPT
{
return size();
}
@ -445,7 +445,7 @@ namespace etl
//*************************************************************************
/// Assign from a view.
//*************************************************************************
array_view& operator=(const array_view& other)
array_view& operator=(const array_view& other) ETL_NOEXCEPT
{
mbegin = other.mbegin;
mend = other.mend;
@ -477,7 +477,7 @@ namespace etl
//*************************************************************************
/// Returns a reference to the indexed value.
//*************************************************************************
reference operator[](const size_t i)
reference operator[](const size_t i) ETL_NOEXCEPT
{
return mbegin[i];
}
@ -486,7 +486,7 @@ namespace etl
//*************************************************************************
/// Returns a const reference to the indexed value.
//*************************************************************************
const_reference operator[](const size_t i) const
const_reference operator[](const size_t i) const ETL_NOEXCEPT
{
return mbegin[i];
}
@ -516,7 +516,7 @@ namespace etl
//*************************************************************************
/// Swaps with another array_view.
//*************************************************************************
void swap(array_view& other)
void swap(array_view& other) ETL_NOEXCEPT
{
using ETL_OR_STD::swap; // Allow ADL
@ -527,7 +527,7 @@ namespace etl
//*************************************************************************
/// Shrinks the view by moving its start forward.
//*************************************************************************
void remove_prefix(const size_type n)
void remove_prefix(const size_type n) ETL_NOEXCEPT
{
if (n < size())
mbegin += n;
@ -538,7 +538,7 @@ namespace etl
//*************************************************************************
/// Shrinks the view by moving its end backward.
//*************************************************************************
void remove_suffix(const size_type n)
void remove_suffix(const size_type n) ETL_NOEXCEPT
{
if (n < size())
mend -= n;
@ -647,7 +647,7 @@ namespace etl
/// Swaps the values.
//*************************************************************************
template <typename T>
void swap(etl::array_view<T>& lhs, etl::array_view<T>& rhs)
void swap(etl::array_view<T>& lhs, etl::array_view<T>& rhs) ETL_NOEXCEPT
{
lhs.swap(rhs);
}

View File

@ -141,7 +141,7 @@ namespace etl
//*************************************************************************
/// Returns a pointer to the first element of the internal storage.
//*************************************************************************
pointer data()
pointer data() ETL_NOEXCEPT
{
return &ARRAY_[BEGIN];
}
@ -149,7 +149,7 @@ namespace etl
//*************************************************************************
/// Returns a const pointer to the first element of the internal storage.
//*************************************************************************
ETL_CONSTEXPR const_pointer data() const
ETL_CONSTEXPR const_pointer data() const ETL_NOEXCEPT
{
return &ARRAY_[BEGIN];
}
@ -157,7 +157,7 @@ namespace etl
//*************************************************************************
/// Returns an iterator to the beginning of the array.
//*************************************************************************
iterator begin()
iterator begin() ETL_NOEXCEPT
{
return &ARRAY_[BEGIN];
}
@ -165,7 +165,7 @@ namespace etl
//*************************************************************************
/// Returns a const iterator to the beginning of the array.
//*************************************************************************
ETL_CONSTEXPR const_iterator begin() const
ETL_CONSTEXPR const_iterator begin() const ETL_NOEXCEPT
{
return &ARRAY_[BEGIN];
}
@ -173,7 +173,7 @@ namespace etl
//*************************************************************************
/// Returns a const iterator to the beginning of the array.
//*************************************************************************
ETL_CONSTEXPR const_iterator cbegin() const
ETL_CONSTEXPR const_iterator cbegin() const ETL_NOEXCEPT
{
return &ARRAY_[BEGIN];
}
@ -181,7 +181,7 @@ namespace etl
//*************************************************************************
/// Returns an iterator to the end of the array.
//*************************************************************************
iterator end()
iterator end() ETL_NOEXCEPT
{
return &ARRAY_[END];
}
@ -189,7 +189,7 @@ namespace etl
//*************************************************************************
/// Returns a const iterator to the end of the array.
//*************************************************************************
ETL_CONSTEXPR const_iterator end() const
ETL_CONSTEXPR const_iterator end() const ETL_NOEXCEPT
{
return &ARRAY_[END];
}
@ -197,7 +197,7 @@ namespace etl
//*************************************************************************
// Returns a const iterator to the end of the array.
//*************************************************************************
ETL_CONSTEXPR const_iterator cend() const
ETL_CONSTEXPR const_iterator cend() const ETL_NOEXCEPT
{
return &ARRAY_[END];
}
@ -205,7 +205,7 @@ namespace etl
//*************************************************************************
// Returns an reverse iterator to the reverse beginning of the array.
//*************************************************************************
reverse_iterator rbegin()
reverse_iterator rbegin() ETL_NOEXCEPT
{
return reverse_iterator(&ARRAY_[END]);
}
@ -213,7 +213,7 @@ namespace etl
//*************************************************************************
/// Returns a const reverse iterator to the reverse beginning of the array.
//*************************************************************************
ETL_CONSTEXPR const_reverse_iterator rbegin() const
ETL_CONSTEXPR const_reverse_iterator rbegin() const ETL_NOEXCEPT
{
return const_reverse_iterator(&ARRAY_[END]);
}
@ -221,7 +221,7 @@ namespace etl
//*************************************************************************
/// Returns a const reverse iterator to the reverse beginning of the array.
//*************************************************************************
ETL_CONSTEXPR const_reverse_iterator crbegin() const
ETL_CONSTEXPR const_reverse_iterator crbegin() const ETL_NOEXCEPT
{
return const_reverse_iterator(&ARRAY_[END]);
}
@ -229,7 +229,7 @@ namespace etl
//*************************************************************************
/// Returns a reverse iterator to the end of the array.
//*************************************************************************
reverse_iterator rend()
reverse_iterator rend() ETL_NOEXCEPT
{
return reverse_iterator(&ARRAY_[BEGIN]);
}
@ -237,7 +237,7 @@ namespace etl
//*************************************************************************
/// Returns a const reverse iterator to the end of the array.
//*************************************************************************
ETL_CONSTEXPR const_reverse_iterator rend() const
ETL_CONSTEXPR const_reverse_iterator rend() const ETL_NOEXCEPT
{
return const_reverse_iterator(&ARRAY_[BEGIN]);
}
@ -245,7 +245,7 @@ namespace etl
//*************************************************************************
/// Returns a const reverse iterator to the end of the array.
//*************************************************************************
ETL_CONSTEXPR const_reverse_iterator crend() const
ETL_CONSTEXPR const_reverse_iterator crend() const ETL_NOEXCEPT
{
return const_reverse_iterator(&ARRAY_[BEGIN]);
}
@ -253,7 +253,7 @@ namespace etl
//*************************************************************************
/// Returns the size of the array.
//*************************************************************************
ETL_CONSTEXPR size_t size() const
ETL_CONSTEXPR size_t size() const ETL_NOEXCEPT
{
return SIZE;
}
@ -261,7 +261,7 @@ namespace etl
//*************************************************************************
/// Returns the maximum possible size of the array.
//*************************************************************************
ETL_CONSTEXPR size_t max_size() const
ETL_CONSTEXPR size_t max_size() const ETL_NOEXCEPT
{
return MAX_SIZE;
}
@ -269,7 +269,7 @@ namespace etl
//*************************************************************************
/// Returns a reference to the indexed value.
//*************************************************************************
reference operator[](size_t i)
reference operator[](size_t i) ETL_NOEXCEPT
{
return ARRAY_[i];
}
@ -277,7 +277,7 @@ namespace etl
//*************************************************************************
/// Returns a const reference to the indexed value.
//*************************************************************************
ETL_CONSTEXPR const_reference operator[](size_t i) const
ETL_CONSTEXPR const_reference operator[](size_t i) const ETL_NOEXCEPT
{
return ARRAY_[i];
}

View File

@ -125,19 +125,19 @@ namespace etl
typedef typename char_traits_types<T>::state_type state_type;
//*************************************************************************
static ETL_CONSTEXPR bool eq(char_type a, char_type b)
static ETL_CONSTEXPR bool eq(char_type a, char_type b) ETL_NOEXCEPT
{
return a == b;
}
//*************************************************************************
static ETL_CONSTEXPR bool lt(char_type a, char_type b)
static ETL_CONSTEXPR bool lt(char_type a, char_type b) ETL_NOEXCEPT
{
return a < b;
}
//*************************************************************************
static ETL_CONSTEXPR14 size_t length(const char_type* begin)
static ETL_CONSTEXPR14 size_t length(const char_type* begin) ETL_NOEXCEPT
{
if (begin == ETL_NULLPTR)
{
@ -155,7 +155,7 @@ namespace etl
}
//*************************************************************************
static ETL_CONSTEXPR14 size_t length(const char_type* str, size_t max_length)
static ETL_CONSTEXPR14 size_t length(const char_type* str, size_t max_length) ETL_NOEXCEPT
{
size_t count = 0UL;
@ -171,13 +171,13 @@ namespace etl
}
//*************************************************************************
static ETL_CONSTEXPR14 void assign(char_type& r, const char_type& c)
static ETL_CONSTEXPR14 void assign(char_type& r, const char_type& c) ETL_NOEXCEPT
{
r = c;
}
//*************************************************************************
static ETL_CONSTEXPR14 char_type* assign(char_type* p, size_t n, char_type c)
static ETL_CONSTEXPR14 char_type* assign(char_type* p, size_t n, char_type c) ETL_NOEXCEPT
{
if (p != ETL_NULLPTR)
{
@ -188,7 +188,7 @@ namespace etl
}
//*************************************************************************
static ETL_CONSTEXPR14 char_type* move(char_type* dst, const char_type* src, size_t count)
static ETL_CONSTEXPR14 char_type* move(char_type* dst, const char_type* src, size_t count) ETL_NOEXCEPT
{
if ((dst < src) || (dst > (src + count)))
{
@ -205,7 +205,7 @@ namespace etl
}
//*************************************************************************
static ETL_CONSTEXPR14 char_type* copy(char_type* dst, const char_type* src, size_t count)
static ETL_CONSTEXPR14 char_type* copy(char_type* dst, const char_type* src, size_t count) ETL_NOEXCEPT
{
etl::copy_n(src, count, dst);
@ -213,7 +213,7 @@ namespace etl
}
//*************************************************************************
static ETL_CONSTEXPR14 int compare(const char_type* s1, const char_type* s2, size_t count)
static ETL_CONSTEXPR14 int compare(const char_type* s1, const char_type* s2, size_t count) ETL_NOEXCEPT
{
for (size_t i = 0UL; i < count; ++i)
{
@ -234,7 +234,7 @@ namespace etl
}
//*************************************************************************
static ETL_CONSTEXPR14 const char_type* find(const char_type* p, size_t count, const char_type& ch)
static ETL_CONSTEXPR14 const char_type* find(const char_type* p, size_t count, const char_type& ch) ETL_NOEXCEPT
{
for (size_t i = 0UL; i < count; ++i)
{
@ -250,31 +250,31 @@ namespace etl
}
//*************************************************************************
static ETL_CONSTEXPR char_type to_char_type(int_type c)
static ETL_CONSTEXPR char_type to_char_type(int_type c) ETL_NOEXCEPT
{
return static_cast<char_type>(c);
}
//*************************************************************************
static ETL_CONSTEXPR int_type to_int_type(char_type c)
static ETL_CONSTEXPR int_type to_int_type(char_type c) ETL_NOEXCEPT
{
return static_cast<int_type>(c);
}
//*************************************************************************
static ETL_CONSTEXPR bool eq_int_type(int_type c1, int_type c2)
static ETL_CONSTEXPR bool eq_int_type(int_type c1, int_type c2) ETL_NOEXCEPT
{
return (c1 == c2);
}
//*************************************************************************
static ETL_CONSTEXPR int_type eof()
static ETL_CONSTEXPR int_type eof() ETL_NOEXCEPT
{
return -1;
}
//*************************************************************************
static ETL_CONSTEXPR int_type not_eof(int_type e)
static ETL_CONSTEXPR int_type not_eof(int_type e) ETL_NOEXCEPT
{
return (e == eof()) ? eof() - 1 : e;
}
@ -284,7 +284,7 @@ namespace etl
/// Alternative strlen for all character types.
//***************************************************************************
template <typename T>
ETL_CONSTEXPR14 size_t strlen(const T* t)
ETL_CONSTEXPR14 size_t strlen(const T* t) ETL_NOEXCEPT
{
return etl::char_traits<T>::length(t);
}
@ -293,7 +293,7 @@ namespace etl
/// Alternative strlen for all character types, with maximum length.
//***************************************************************************
template <typename T>
ETL_CONSTEXPR14 size_t strlen(const T* t, size_t max_length)
ETL_CONSTEXPR14 size_t strlen(const T* t, size_t max_length) ETL_NOEXCEPT
{
return etl::char_traits<T>::length(t, max_length);
}
@ -302,7 +302,7 @@ namespace etl
/// Alternative strcmp for all character types.
//***************************************************************************
template <typename T>
ETL_CONSTEXPR14 int strcmp(const T* t1, const T* t2)
ETL_CONSTEXPR14 int strcmp(const T* t1, const T* t2) ETL_NOEXCEPT
{
while ((*t1 != 0) || (*t2 != 0))
{
@ -327,7 +327,7 @@ namespace etl
/// Alternative strncmp for all character types.
//***************************************************************************
template <typename T>
ETL_CONSTEXPR14 int strncmp(const T* t1, const T* t2, size_t n)
ETL_CONSTEXPR14 int strncmp(const T* t1, const T* t2, size_t n) ETL_NOEXCEPT
{
while (((*t1 != 0) || (*t2 != 0)) && (n != 0))
{
@ -352,7 +352,7 @@ namespace etl
/// Alternative strcpy for all character types.
//***************************************************************************
template <typename T>
ETL_CONSTEXPR14 T* strcpy(T* dst, const T* src)
ETL_CONSTEXPR14 T* strcpy(T* dst, const T* src) ETL_NOEXCEPT
{
T* result = dst;
@ -370,7 +370,7 @@ namespace etl
/// Alternative strncpy for all character types.
//***************************************************************************
template <typename T>
ETL_CONSTEXPR14 T* strncpy(T* dst, const T* src, size_t n)
ETL_CONSTEXPR14 T* strncpy(T* dst, const T* src, size_t n) ETL_NOEXCEPT
{
T* result = dst;

View File

@ -59,7 +59,7 @@ namespace etl
/// Defined when not using the STL or C++20
//*****************************************************************************
template <typename T>
ETL_CONSTEXPR T* to_address(T* p)
ETL_CONSTEXPR T* to_address(T* p) ETL_NOEXCEPT
{
return p;
}
@ -70,7 +70,7 @@ namespace etl
/// Defined when not using the STL or C++20
//*****************************************************************************
template <typename Iterator>
ETL_CONSTEXPR typename Iterator::pointer to_address(const Iterator& itr)
ETL_CONSTEXPR typename Iterator::pointer to_address(const Iterator& itr) ETL_NOEXCEPT
{
return etl::to_address(itr.operator->());
}

View File

@ -333,6 +333,7 @@ SOFTWARE.
#define ETL_LVALUE_REF_QUALIFIER &
#define ETL_NOEXCEPT noexcept
#define ETL_NOEXCEPT_EXPR(...) noexcept(__VA_ARGS__)
#define ETL_NOEXCEPT_FROM(x) noexcept(noexcept(x))
#else
#define ETL_CONSTEXPR
#define ETL_CONSTEXPR11
@ -344,6 +345,7 @@ SOFTWARE.
#define ETL_NORETURN
#define ETL_NOEXCEPT
#define ETL_NOEXCEPT_EXPR(...)
#define ETL_NOEXCEPT_FROM(x)
#define ETL_MOVE(x) x
#define ETL_ENUM_CLASS(name) enum name
#define ETL_ENUM_CLASS_TYPE(name, type) enum name

View File

@ -141,7 +141,7 @@ namespace etl
/// Construct from iterators
//*************************************************************************
template <typename TIterator>
ETL_CONSTEXPR explicit span(const TIterator begin_, const TIterator /*end_*/)
ETL_CONSTEXPR explicit span(const TIterator begin_, const TIterator /*end_*/) ETL_NOEXCEPT
: pbegin(etl::to_address(begin_))
{
}
@ -585,7 +585,7 @@ namespace etl
/// Construct from iterators
//*************************************************************************
template <typename TIterator>
ETL_CONSTEXPR span(const TIterator begin_, const TIterator end_)
ETL_CONSTEXPR span(const TIterator begin_, const TIterator end_) ETL_NOEXCEPT
: pbegin(etl::to_address(begin_))
, pend(etl::to_address(begin_) + etl::distance(begin_, end_))
{

View File

@ -132,7 +132,7 @@ namespace etl
//*************************************************************************
/// Construct from string.
//*************************************************************************
ETL_CONSTEXPR basic_string_view(const etl::ibasic_string<T>& str)
ETL_CONSTEXPR basic_string_view(const etl::ibasic_string<T>& str) ETL_NOEXCEPT
: mbegin(str.begin())
, mend(str.end())
{
@ -141,7 +141,7 @@ namespace etl
//*************************************************************************
/// Construct from T*.
//*************************************************************************
ETL_CONSTEXPR14 ETL_EXPLICIT_STRING_FROM_CHAR basic_string_view(const T* begin_)
ETL_CONSTEXPR14 ETL_EXPLICIT_STRING_FROM_CHAR basic_string_view(const T* begin_) ETL_NOEXCEPT
: mbegin(begin_)
, mend(begin_ + TTraits::length(begin_))
{
@ -150,7 +150,7 @@ namespace etl
//*************************************************************************
/// Construct from pointer range.
//*************************************************************************
ETL_CONSTEXPR basic_string_view(const T* begin_, const T* end_)
ETL_CONSTEXPR basic_string_view(const T* begin_, const T* end_) ETL_NOEXCEPT
: mbegin(begin_)
, mend(end_)
{
@ -159,7 +159,7 @@ namespace etl
//*************************************************************************
/// Construct from pointer/size.
//*************************************************************************
ETL_CONSTEXPR basic_string_view(const T* begin_, size_t size_)
ETL_CONSTEXPR basic_string_view(const T* begin_, size_t size_) ETL_NOEXCEPT
: mbegin(begin_)
, mend(begin_ + size_)
{
@ -193,7 +193,7 @@ namespace etl
//*************************************************************************
/// Returns a const pointer to the first element of the internal storage.
//*************************************************************************
ETL_CONSTEXPR const_pointer data() const
ETL_CONSTEXPR const_pointer data() const ETL_NOEXCEPT
{
return mbegin;
}
@ -201,7 +201,7 @@ namespace etl
//*************************************************************************
/// Returns a const iterator to the beginning of the array.
//*************************************************************************
ETL_CONSTEXPR const_iterator begin() const
ETL_CONSTEXPR const_iterator begin() const ETL_NOEXCEPT
{
return mbegin;
}
@ -209,7 +209,7 @@ namespace etl
//*************************************************************************
/// Returns a const iterator to the beginning of the array.
//*************************************************************************
ETL_CONSTEXPR const_iterator cbegin() const
ETL_CONSTEXPR const_iterator cbegin() const ETL_NOEXCEPT
{
return mbegin;
}
@ -217,7 +217,7 @@ namespace etl
//*************************************************************************
/// Returns a const iterator to the end of the array.
//*************************************************************************
ETL_CONSTEXPR const_iterator end() const
ETL_CONSTEXPR const_iterator end() const ETL_NOEXCEPT
{
return mend;
}
@ -225,7 +225,7 @@ namespace etl
//*************************************************************************
// Returns a const iterator to the end of the array.
//*************************************************************************
ETL_CONSTEXPR const_iterator cend() const
ETL_CONSTEXPR const_iterator cend() const ETL_NOEXCEPT
{
return mend;
}
@ -233,7 +233,7 @@ namespace etl
//*************************************************************************
/// Returns a const reverse iterator to the reverse beginning of the array.
//*************************************************************************
ETL_CONSTEXPR const_reverse_iterator rbegin() const
ETL_CONSTEXPR const_reverse_iterator rbegin() const ETL_NOEXCEPT
{
return const_reverse_iterator(mend);
}
@ -241,7 +241,7 @@ namespace etl
//*************************************************************************
/// Returns a const reverse iterator to the reverse beginning of the array.
//*************************************************************************
ETL_CONSTEXPR const_reverse_iterator crbegin() const
ETL_CONSTEXPR const_reverse_iterator crbegin() const ETL_NOEXCEPT
{
return const_reverse_iterator(mend);
}
@ -249,7 +249,7 @@ namespace etl
//*************************************************************************
/// Returns a const reverse iterator to the end of the array.
//*************************************************************************
ETL_CONSTEXPR const_reverse_iterator rend() const
ETL_CONSTEXPR const_reverse_iterator rend() const ETL_NOEXCEPT
{
return const_reverse_iterator(mbegin);
}
@ -257,7 +257,7 @@ namespace etl
//*************************************************************************
/// Returns a const reverse iterator to the end of the array.
//*************************************************************************
ETL_CONSTEXPR const_reverse_iterator crend() const
ETL_CONSTEXPR const_reverse_iterator crend() const ETL_NOEXCEPT
{
return const_reverse_iterator(mbegin);
}
@ -269,7 +269,7 @@ namespace etl
//*************************************************************************
/// Returns <b>true</b> if the array size is zero.
//*************************************************************************
ETL_CONSTEXPR bool empty() const
ETL_CONSTEXPR bool empty() const ETL_NOEXCEPT
{
return (mbegin == mend);
}
@ -277,7 +277,7 @@ namespace etl
//*************************************************************************
/// Returns the size of the array.
//*************************************************************************
ETL_CONSTEXPR size_t size() const
ETL_CONSTEXPR size_t size() const ETL_NOEXCEPT
{
return static_cast<size_t>(mend - mbegin);
}
@ -285,7 +285,7 @@ namespace etl
//*************************************************************************
/// Returns the size of the array.
//*************************************************************************
ETL_CONSTEXPR size_t length() const
ETL_CONSTEXPR size_t length() const ETL_NOEXCEPT
{
return size();
}
@ -293,7 +293,7 @@ namespace etl
//*************************************************************************
/// Returns the maximum possible size of the array.
//*************************************************************************
ETL_CONSTEXPR size_t max_size() const
ETL_CONSTEXPR size_t max_size() const ETL_NOEXCEPT
{
return size();
}
@ -301,7 +301,7 @@ namespace etl
//*************************************************************************
/// Assign from a view.
//*************************************************************************
ETL_CONSTEXPR14 etl::basic_string_view<T, TTraits>& operator=(const etl::basic_string_view<T, TTraits>& other)
ETL_CONSTEXPR14 etl::basic_string_view<T, TTraits>& operator=(const etl::basic_string_view<T, TTraits>& other) ETL_NOEXCEPT
{
mbegin = other.mbegin;
mend = other.mend;
@ -311,7 +311,7 @@ namespace etl
//*************************************************************************
/// Assign from iterators
//*************************************************************************
ETL_CONSTEXPR14 void assign(const_pointer begin_, const_pointer end_)
ETL_CONSTEXPR14 void assign(const_pointer begin_, const_pointer end_) ETL_NOEXCEPT
{
mbegin = begin_;
mend = end_;
@ -320,7 +320,7 @@ namespace etl
//*************************************************************************
/// Assign from iterator and size.
//*************************************************************************
ETL_CONSTEXPR14 void assign(const_pointer begin_, size_t size_)
ETL_CONSTEXPR14 void assign(const_pointer begin_, size_t size_) ETL_NOEXCEPT
{
mbegin = begin_;
mend = begin_ + size_;
@ -329,7 +329,7 @@ namespace etl
//*************************************************************************
/// Returns a const reference to the indexed value.
//*************************************************************************
ETL_CONSTEXPR const_reference operator[](size_t i) const
ETL_CONSTEXPR const_reference operator[](size_t i) const ETL_NOEXCEPT
{
return mbegin[i];
}
@ -358,7 +358,7 @@ namespace etl
//*************************************************************************
/// Copies characters
//*************************************************************************
ETL_CONSTEXPR14 size_type copy(T* destination, size_type count, size_type position = 0) const
ETL_CONSTEXPR14 size_type copy(T* destination, size_type count, size_type position = 0) const ETL_NOEXCEPT
{
size_t n = 0UL;
@ -375,7 +375,7 @@ namespace etl
//*************************************************************************
/// Returns a substring
//*************************************************************************
ETL_CONSTEXPR14 basic_string_view substr(size_type position = 0, size_type count = npos) const
ETL_CONSTEXPR14 basic_string_view substr(size_type position = 0, size_type count = npos) const ETL_NOEXCEPT
{
basic_string_view view = basic_string_view();
@ -392,7 +392,7 @@ namespace etl
//*************************************************************************
/// Shrinks the view by moving its start forward.
//*************************************************************************
ETL_CONSTEXPR14 void remove_prefix(size_type n)
ETL_CONSTEXPR14 void remove_prefix(size_type n) ETL_NOEXCEPT
{
mbegin += n;
}
@ -400,7 +400,7 @@ namespace etl
//*************************************************************************
/// Shrinks the view by moving its end backward.
//*************************************************************************
ETL_CONSTEXPR14 void remove_suffix(size_type n)
ETL_CONSTEXPR14 void remove_suffix(size_type n) ETL_NOEXCEPT
{
mend -= n;
}
@ -408,24 +408,24 @@ namespace etl
//*************************************************************************
/// Compares two views
//*************************************************************************
ETL_CONSTEXPR14 int compare(basic_string_view<T, TTraits> view) const
ETL_CONSTEXPR14 int compare(basic_string_view<T, TTraits> view) const ETL_NOEXCEPT
{
return (*this == view) ? 0 : ((*this > view) ? 1 : -1);
}
ETL_CONSTEXPR14 int compare(size_type position, size_type count, basic_string_view view) const
ETL_CONSTEXPR14 int compare(size_type position, size_type count, basic_string_view view) const ETL_NOEXCEPT
{
return substr(position, count).compare(view);
}
ETL_CONSTEXPR14 int compare(size_type position1, size_type count1,
basic_string_view view,
size_type position2, size_type count2) const
size_type position2, size_type count2) const ETL_NOEXCEPT
{
return substr(position1, count1).compare(view.substr(position2, count2));
}
ETL_CONSTEXPR14 int compare(const T* text) const
ETL_CONSTEXPR14 int compare(const T* text) const ETL_NOEXCEPT
{
const T* view_itr = mbegin;
const T* text_itr = text;
@ -458,12 +458,12 @@ namespace etl
}
}
ETL_CONSTEXPR14 int compare(size_type position, size_type count, const T* text) const
ETL_CONSTEXPR14 int compare(size_type position, size_type count, const T* text) const ETL_NOEXCEPT
{
return substr(position, count).compare(text);
}
ETL_CONSTEXPR14 int compare(size_type position, size_type count1, const T* text, size_type count2) const
ETL_CONSTEXPR14 int compare(size_type position, size_type count1, const T* text, size_type count2) const ETL_NOEXCEPT
{
return substr(position, count1).compare(etl::basic_string_view<T, TTraits>(text, count2));
}
@ -471,18 +471,18 @@ namespace etl
//*************************************************************************
/// Checks if the string view starts with the given prefix
//*************************************************************************
ETL_CONSTEXPR14 bool starts_with(etl::basic_string_view<T, TTraits> view) const
ETL_CONSTEXPR14 bool starts_with(etl::basic_string_view<T, TTraits> view) const ETL_NOEXCEPT
{
return (size() >= view.size()) &&
(compare(0, view.size(), view) == 0);
}
ETL_CONSTEXPR14 bool starts_with(T c) const
ETL_CONSTEXPR14 bool starts_with(T c) const ETL_NOEXCEPT
{
return !empty() && (front() == c);
}
ETL_CONSTEXPR14 bool starts_with(const T* text) const
ETL_CONSTEXPR14 bool starts_with(const T* text) const ETL_NOEXCEPT
{
size_t lengthtext = TTraits::length(text);
@ -493,7 +493,7 @@ namespace etl
//*************************************************************************
/// Checks if the string view ends with the given suffix
//*************************************************************************
ETL_CONSTEXPR14 bool ends_with(etl::basic_string_view<T, TTraits> view) const
ETL_CONSTEXPR14 bool ends_with(etl::basic_string_view<T, TTraits> view) const ETL_NOEXCEPT
{
return (size() >= view.size()) &&
(compare(size() - view.size(), npos, view) == 0);
@ -516,7 +516,7 @@ namespace etl
//*************************************************************************
/// Find characters in the view
//*************************************************************************
ETL_CONSTEXPR14 size_type find(etl::basic_string_view<T, TTraits> view, size_type position = 0) const
ETL_CONSTEXPR14 size_type find(etl::basic_string_view<T, TTraits> view, size_type position = 0) const ETL_NOEXCEPT
{
if ((size() < view.size()))
{
@ -535,17 +535,17 @@ namespace etl
}
}
ETL_CONSTEXPR14 size_type find(T c, size_type position = 0) const
ETL_CONSTEXPR14 size_type find(T c, size_type position = 0) const ETL_NOEXCEPT
{
return find(etl::basic_string_view<T, TTraits>(&c, 1), position);
}
ETL_CONSTEXPR14 size_type find(const T* text, size_type position, size_type count) const
ETL_CONSTEXPR14 size_type find(const T* text, size_type position, size_type count) const ETL_NOEXCEPT
{
return find(etl::basic_string_view<T, TTraits>(text, count), position);
}
ETL_CONSTEXPR14 size_type find(const T* text, size_type position = 0) const
ETL_CONSTEXPR14 size_type find(const T* text, size_type position = 0) const ETL_NOEXCEPT
{
return find(etl::basic_string_view<T, TTraits>(text), position);
}
@ -553,7 +553,7 @@ namespace etl
//*************************************************************************
/// Find the last occurrence of a substring
//*************************************************************************
ETL_CONSTEXPR14 size_type rfind(etl::basic_string_view<T, TTraits> view, size_type position = npos) const
ETL_CONSTEXPR14 size_type rfind(etl::basic_string_view<T, TTraits> view, size_type position = npos) const ETL_NOEXCEPT
{
if ((size() < view.size()))
{
@ -577,17 +577,17 @@ namespace etl
}
}
ETL_CONSTEXPR14 size_type rfind(T c, size_type position = npos) const
ETL_CONSTEXPR14 size_type rfind(T c, size_type position = npos) const ETL_NOEXCEPT
{
return rfind(etl::basic_string_view<T, TTraits>(&c, 1), position);
}
ETL_CONSTEXPR14 size_type rfind(const T* text, size_type position, size_type count) const
ETL_CONSTEXPR14 size_type rfind(const T* text, size_type position, size_type count) const ETL_NOEXCEPT
{
return rfind(etl::basic_string_view<T, TTraits>(text, count), position);
}
ETL_CONSTEXPR14 size_type rfind(const T* text, size_type position = npos) const
ETL_CONSTEXPR14 size_type rfind(const T* text, size_type position = npos) const ETL_NOEXCEPT
{
return rfind(etl::basic_string_view<T, TTraits>(text), position);
}
@ -595,7 +595,7 @@ namespace etl
//*************************************************************************
/// Find first occurrence of characters
//*************************************************************************
ETL_CONSTEXPR14 size_type find_first_of(etl::basic_string_view<T, TTraits> view, size_type position = 0) const
ETL_CONSTEXPR14 size_type find_first_of(etl::basic_string_view<T, TTraits> view, size_type position = 0) const ETL_NOEXCEPT
{
const size_t lengthtext = size();
@ -618,17 +618,17 @@ namespace etl
return npos;
}
ETL_CONSTEXPR14 size_type find_first_of(T c, size_type position = 0) const
ETL_CONSTEXPR14 size_type find_first_of(T c, size_type position = 0) const ETL_NOEXCEPT
{
return find_first_of(etl::basic_string_view<T, TTraits>(&c, 1), position);
}
ETL_CONSTEXPR14 size_type find_first_of(const T* text, size_type position, size_type count) const
ETL_CONSTEXPR14 size_type find_first_of(const T* text, size_type position, size_type count) const ETL_NOEXCEPT
{
return find_first_of(etl::basic_string_view<T, TTraits>(text, count), position);
}
ETL_CONSTEXPR14 size_type find_first_of(const T* text, size_type position = 0) const
ETL_CONSTEXPR14 size_type find_first_of(const T* text, size_type position = 0) const ETL_NOEXCEPT
{
return find_first_of(etl::basic_string_view<T, TTraits>(text), position);
}
@ -636,7 +636,7 @@ namespace etl
//*************************************************************************
/// Find last occurrence of characters
//*************************************************************************
ETL_CONSTEXPR14 size_type find_last_of(etl::basic_string_view<T, TTraits> view, size_type position = npos) const
ETL_CONSTEXPR14 size_type find_last_of(etl::basic_string_view<T, TTraits> view, size_type position = npos) const ETL_NOEXCEPT
{
if (empty())
{
@ -666,17 +666,17 @@ namespace etl
return npos;
}
ETL_CONSTEXPR14 size_type find_last_of(T c, size_type position = npos) const
ETL_CONSTEXPR14 size_type find_last_of(T c, size_type position = npos) const ETL_NOEXCEPT
{
return find_last_of(etl::basic_string_view<T, TTraits>(&c, 1), position);
}
ETL_CONSTEXPR14 size_type find_last_of(const T* text, size_type position, size_type count) const
ETL_CONSTEXPR14 size_type find_last_of(const T* text, size_type position, size_type count) const ETL_NOEXCEPT
{
return find_last_of(etl::basic_string_view<T, TTraits>(text, count), position);
}
ETL_CONSTEXPR14 size_type find_last_of(const T* text, size_type position = npos) const
ETL_CONSTEXPR14 size_type find_last_of(const T* text, size_type position = npos) const ETL_NOEXCEPT
{
return find_last_of(etl::basic_string_view<T, TTraits>(text), position);
}
@ -684,7 +684,7 @@ namespace etl
//*************************************************************************
/// Find first absence of characters
//*************************************************************************
ETL_CONSTEXPR14 size_type find_first_not_of(etl::basic_string_view<T, TTraits> view, size_type position = 0) const
ETL_CONSTEXPR14 size_type find_first_not_of(etl::basic_string_view<T, TTraits> view, size_type position = 0) const ETL_NOEXCEPT
{
const size_t lengthtext = size();
@ -715,17 +715,17 @@ namespace etl
return npos;
}
ETL_CONSTEXPR14 size_type find_first_not_of(T c, size_type position = 0) const
ETL_CONSTEXPR14 size_type find_first_not_of(T c, size_type position = 0) const ETL_NOEXCEPT
{
return find_first_not_of(etl::basic_string_view<T, TTraits>(&c, 1), position);
}
ETL_CONSTEXPR14 size_type find_first_not_of(const T* text, size_type position, size_type count) const
ETL_CONSTEXPR14 size_type find_first_not_of(const T* text, size_type position, size_type count) const ETL_NOEXCEPT
{
return find_first_not_of(etl::basic_string_view<T, TTraits>(text, count), position);
}
ETL_CONSTEXPR14 size_type find_first_not_of(const T* text, size_type position = 0) const
ETL_CONSTEXPR14 size_type find_first_not_of(const T* text, size_type position = 0) const ETL_NOEXCEPT
{
return find_first_not_of(etl::basic_string_view<T, TTraits>(text), position);
}
@ -733,7 +733,7 @@ namespace etl
//*************************************************************************
/// Find last absence of characters
//*************************************************************************
ETL_CONSTEXPR14 size_type find_last_not_of(etl::basic_string_view<T, TTraits> view, size_type position = npos) const
ETL_CONSTEXPR14 size_type find_last_not_of(etl::basic_string_view<T, TTraits> view, size_type position = npos) const ETL_NOEXCEPT
{
if (empty())
{
@ -771,17 +771,17 @@ namespace etl
return npos;
}
ETL_CONSTEXPR14 size_type find_last_not_of(T c, size_type position = npos) const
ETL_CONSTEXPR14 size_type find_last_not_of(T c, size_type position = npos) const ETL_NOEXCEPT
{
return find_last_not_of(etl::basic_string_view<T, TTraits>(&c, 1), position);
}
ETL_CONSTEXPR14 size_type find_last_not_of(const T* text, size_type position, size_type count) const
ETL_CONSTEXPR14 size_type find_last_not_of(const T* text, size_type position, size_type count) const ETL_NOEXCEPT
{
return find_last_not_of(etl::basic_string_view<T, TTraits>(text, count), position);
}
ETL_CONSTEXPR14 size_type find_last_not_of(const T* text, size_type position = npos) const
ETL_CONSTEXPR14 size_type find_last_not_of(const T* text, size_type position = npos) const ETL_NOEXCEPT
{
return find_last_not_of(etl::basic_string_view<T, TTraits>(text), position);
}
@ -789,7 +789,7 @@ namespace etl
//*********************************************************************
/// Checks that the view is within this string
//*********************************************************************
bool contains(const etl::basic_string_view<T, TTraits>& view) const
bool contains(const etl::basic_string_view<T, TTraits>& view) const ETL_NOEXCEPT
{
return find(view) != npos;
}
@ -797,7 +797,7 @@ namespace etl
//*********************************************************************
/// Checks that text is within this string
//*********************************************************************
bool contains(const_pointer s) const
bool contains(const_pointer s) const ETL_NOEXCEPT
{
return find(s) != npos;
}
@ -805,7 +805,7 @@ namespace etl
//*********************************************************************
/// Checks that character is within this string
//*********************************************************************
bool contains(value_type c) const
bool contains(value_type c) const ETL_NOEXCEPT
{
return find(c) != npos;
}
@ -875,7 +875,7 @@ namespace etl
/// make_string_view.
//*************************************************************************
template<size_t Array_Size>
ETL_CONSTEXPR14 string_view make_string_view(const char(&text)[Array_Size])
ETL_CONSTEXPR14 string_view make_string_view(const char(&text)[Array_Size]) ETL_NOEXCEPT
{
size_t length = etl::char_traits<char>::length(text, Array_Size - 1U);
@ -884,7 +884,7 @@ namespace etl
//***********************************
template<size_t Array_Size>
ETL_CONSTEXPR14 wstring_view make_string_view(const wchar_t(&text)[Array_Size])
ETL_CONSTEXPR14 wstring_view make_string_view(const wchar_t(&text)[Array_Size]) ETL_NOEXCEPT
{
size_t length = etl::char_traits<wchar_t>::length(text, Array_Size - 1U);
@ -893,7 +893,7 @@ namespace etl
//***********************************
template<size_t Array_Size>
ETL_CONSTEXPR14 u8string_view make_string_view(const char8_t(&text)[Array_Size])
ETL_CONSTEXPR14 u8string_view make_string_view(const char8_t(&text)[Array_Size]) ETL_NOEXCEPT
{
size_t length = etl::char_traits<char8_t>::length(text, Array_Size - 1U);
@ -902,7 +902,7 @@ namespace etl
//***********************************
template<size_t Array_Size>
ETL_CONSTEXPR14 u16string_view make_string_view(const char16_t(&text)[Array_Size])
ETL_CONSTEXPR14 u16string_view make_string_view(const char16_t(&text)[Array_Size]) ETL_NOEXCEPT
{
size_t length = etl::char_traits<char16_t>::length(text, Array_Size - 1U);
@ -911,7 +911,7 @@ namespace etl
//***********************************
template<size_t Array_Size>
ETL_CONSTEXPR14 u32string_view make_string_view(const char32_t(&text)[Array_Size])
ETL_CONSTEXPR14 u32string_view make_string_view(const char32_t(&text)[Array_Size]) ETL_NOEXCEPT
{
size_t length = etl::char_traits<char32_t>::length(text, Array_Size - 1U);
@ -968,13 +968,13 @@ namespace etl
/// Swaps the values.
//*************************************************************************
template <typename T, typename TTraits >
void swap(etl::basic_string_view<T, TTraits>& lhs, etl::basic_string_view<T, TTraits>& rhs)
void swap(etl::basic_string_view<T, TTraits>& lhs, etl::basic_string_view<T, TTraits>& rhs) ETL_NOEXCEPT
{
lhs.swap(rhs);
}
template <typename T>
void swap(etl::basic_string_view<T, etl::char_traits<T> >& lhs, etl::basic_string_view<T, etl::char_traits<T> >& rhs)
void swap(etl::basic_string_view<T, etl::char_traits<T> >& lhs, etl::basic_string_view<T, etl::char_traits<T> >& rhs) ETL_NOEXCEPT
{
lhs.swap(rhs);
}