Simplify noexcept expressions using ETL_NOT_USING_EXCEPTIONS (#1606)

* Simplify noexcept containing ETL_NOT_USING_EXCEPTIONS

* Revert some format

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
Co-authored-by: Roland Reichwein <Roland.Reichwein@bmw.de>
This commit is contained in:
Mike Bloom 2026-09-17 07:57:10 -04:00 committed by GitHub
parent b1f1977123
commit 22bdef2ee4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 21 additions and 27 deletions

View File

@ -137,7 +137,7 @@ namespace etl
/// Returns a reference to the value at index 'i'. /// Returns a reference to the value at index 'i'.
///\param i The index of the element to access. ///\param i The index of the element to access.
//************************************************************************* //*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR14 reference operator[](size_t i) ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS || ETL_NOT_CHECKING_INDEX_OPERATOR) ETL_NODISCARD ETL_CONSTEXPR14 reference operator[](size_t i) ETL_NOEXCEPT_EXPR(ETL_NOT_CHECKING_INDEX_OPERATOR)
{ {
ETL_ASSERT_CHECK_INDEX_OPERATOR(i < SIZE, ETL_ERROR(array_out_of_range)); ETL_ASSERT_CHECK_INDEX_OPERATOR(i < SIZE, ETL_ERROR(array_out_of_range));
@ -149,7 +149,7 @@ namespace etl
/// Returns a const reference to the value at index 'i'. /// Returns a const reference to the value at index 'i'.
///\param i The index of the element to access. ///\param i The index of the element to access.
//************************************************************************* //*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR const_reference operator[](size_t i) const ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS || ETL_NOT_CHECKING_INDEX_OPERATOR) ETL_NODISCARD ETL_CONSTEXPR const_reference operator[](size_t i) const ETL_NOEXCEPT_EXPR(ETL_NOT_CHECKING_INDEX_OPERATOR)
{ {
// Throwing from c++11 constexpr requires special syntax // Throwing from c++11 constexpr requires special syntax
#if ETL_USING_CPP11 && ETL_NOT_USING_CPP14 && ETL_USING_EXCEPTIONS && ETL_CHECKING_INDEX_OPERATOR #if ETL_USING_CPP11 && ETL_NOT_USING_CPP14 && ETL_USING_EXCEPTIONS && ETL_CHECKING_INDEX_OPERATOR

View File

@ -518,7 +518,7 @@ namespace etl
/// If asserts or exceptions are enabled, throws an etl::array_view_bounds /// If asserts or exceptions are enabled, throws an etl::array_view_bounds
/// if the index is out of bounds. /// if the index is out of bounds.
//************************************************************************* //*************************************************************************
reference operator[](const size_t i) ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS || ETL_NOT_CHECKING_INDEX_OPERATOR) reference operator[](const size_t i) ETL_NOEXCEPT_EXPR(ETL_NOT_CHECKING_INDEX_OPERATOR)
{ {
ETL_ASSERT_CHECK_INDEX_OPERATOR(i < size(), ETL_ERROR(array_view_bounds)); ETL_ASSERT_CHECK_INDEX_OPERATOR(i < size(), ETL_ERROR(array_view_bounds));
@ -531,7 +531,7 @@ namespace etl
/// If asserts or exceptions are enabled, throws an etl::array_view_bounds /// If asserts or exceptions are enabled, throws an etl::array_view_bounds
/// if the index is out of bounds. /// if the index is out of bounds.
//************************************************************************* //*************************************************************************
const_reference operator[](const size_t i) const ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS || ETL_NOT_CHECKING_INDEX_OPERATOR) const_reference operator[](const size_t i) const ETL_NOEXCEPT_EXPR(ETL_NOT_CHECKING_INDEX_OPERATOR)
{ {
ETL_ASSERT_CHECK_INDEX_OPERATOR(i < size(), ETL_ERROR(array_view_bounds)); ETL_ASSERT_CHECK_INDEX_OPERATOR(i < size(), ETL_ERROR(array_view_bounds));

View File

@ -271,7 +271,7 @@ namespace etl
/// If asserts or exceptions are enabled, throws an /// If asserts or exceptions are enabled, throws an
/// etl::array_wrapper_bounds if the index is out of bounds. /// etl::array_wrapper_bounds if the index is out of bounds.
//************************************************************************* //*************************************************************************
reference operator[](size_t i) ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS || ETL_NOT_CHECKING_INDEX_OPERATOR) reference operator[](size_t i) ETL_NOEXCEPT_EXPR(ETL_NOT_CHECKING_INDEX_OPERATOR)
{ {
ETL_ASSERT_CHECK_INDEX_OPERATOR(i < SIZE, ETL_ERROR(etl::array_wrapper_bounds)); ETL_ASSERT_CHECK_INDEX_OPERATOR(i < SIZE, ETL_ERROR(etl::array_wrapper_bounds));
return ARRAY_[i]; return ARRAY_[i];
@ -282,7 +282,7 @@ namespace etl
/// If asserts or exceptions are enabled, throws an /// If asserts or exceptions are enabled, throws an
/// etl::array_wrapper_bounds if the index is out of bounds. /// etl::array_wrapper_bounds if the index is out of bounds.
//************************************************************************* //*************************************************************************
ETL_CONSTEXPR const_reference operator[](size_t i) const ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS || ETL_NOT_CHECKING_INDEX_OPERATOR) ETL_CONSTEXPR const_reference operator[](size_t i) const ETL_NOEXCEPT_EXPR(ETL_NOT_CHECKING_INDEX_OPERATOR)
{ {
// Throwing from c++11 constexpr requires special syntax // Throwing from c++11 constexpr requires special syntax
#if ETL_USING_CPP11 && ETL_NOT_USING_CPP14 && ETL_USING_EXCEPTIONS && ETL_CHECKING_INDEX_OPERATOR #if ETL_USING_CPP11 && ETL_NOT_USING_CPP14 && ETL_USING_EXCEPTIONS && ETL_CHECKING_INDEX_OPERATOR

View File

@ -644,8 +644,7 @@ namespace etl
/// Obtains a span that is a view over the first count elements of this /// Obtains a span that is a view over the first count elements of this
/// span. /// span.
//************************************************************************* //*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR etl::span<element_type, etl::dynamic_extent> first(size_t count) const ETL_NODISCARD ETL_CONSTEXPR etl::span<element_type, etl::dynamic_extent> first(size_t count) const ETL_NOEXCEPT_IF(ETL_NOT_CHECKING_EXTRA)
ETL_NOEXCEPT_IF(ETL_NOT_USING_EXCEPTIONS || ETL_NOT_CHECKING_EXTRA)
{ {
#if ETL_USING_CPP11 && ETL_NOT_USING_CPP14 && ETL_USING_EXCEPTIONS && ETL_CHECKING_EXTRA #if ETL_USING_CPP11 && ETL_NOT_USING_CPP14 && ETL_USING_EXCEPTIONS && ETL_CHECKING_EXTRA
return count <= size() ? etl::span<element_type, etl::dynamic_extent>(pbegin, pbegin + count) : throw(ETL_ERROR(span_out_of_range)); return count <= size() ? etl::span<element_type, etl::dynamic_extent>(pbegin, pbegin + count) : throw(ETL_ERROR(span_out_of_range));
@ -672,8 +671,7 @@ namespace etl
//************************************************************************* //*************************************************************************
/// Obtains a span that is a view over the last count elements of this span. /// Obtains a span that is a view over the last count elements of this span.
//************************************************************************* //*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR etl::span<element_type, etl::dynamic_extent> last(size_t count) const ETL_NODISCARD ETL_CONSTEXPR etl::span<element_type, etl::dynamic_extent> last(size_t count) const ETL_NOEXCEPT_IF(ETL_NOT_CHECKING_EXTRA)
ETL_NOEXCEPT_IF(ETL_NOT_USING_EXCEPTIONS || ETL_NOT_CHECKING_EXTRA)
{ {
#if ETL_USING_CPP11 && ETL_NOT_USING_CPP14 && ETL_USING_EXCEPTIONS && ETL_CHECKING_EXTRA #if ETL_USING_CPP11 && ETL_NOT_USING_CPP14 && ETL_USING_EXCEPTIONS && ETL_CHECKING_EXTRA
return count <= size() ? etl::span<element_type, etl::dynamic_extent>((pbegin + Extent) - count, (pbegin + Extent)) return count <= size() ? etl::span<element_type, etl::dynamic_extent>((pbegin + Extent) - count, (pbegin + Extent))
@ -735,7 +733,7 @@ namespace etl
/// elements of this span. /// elements of this span.
//************************************************************************* //*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR etl::span<element_type, etl::dynamic_extent> subspan(size_t offset, size_t count = etl::dynamic_extent) const ETL_NODISCARD ETL_CONSTEXPR etl::span<element_type, etl::dynamic_extent> subspan(size_t offset, size_t count = etl::dynamic_extent) const
ETL_NOEXCEPT_IF(ETL_NOT_USING_EXCEPTIONS || ETL_NOT_CHECKING_EXTRA) ETL_NOEXCEPT_IF(ETL_NOT_CHECKING_EXTRA)
{ {
#if ETL_USING_CPP11 && ETL_NOT_USING_CPP14 && ETL_USING_EXCEPTIONS && ETL_CHECKING_EXTRA #if ETL_USING_CPP11 && ETL_NOT_USING_CPP14 && ETL_USING_EXCEPTIONS && ETL_CHECKING_EXTRA
return (offset <= size()) && (count != etl::dynamic_extent ? count <= (size() - offset) : true) return (offset <= size()) && (count != etl::dynamic_extent ? count <= (size() - offset) : true)
@ -1003,7 +1001,7 @@ namespace etl
//************************************************************************* //*************************************************************************
/// Returns a reference to the first element. /// Returns a reference to the first element.
//************************************************************************* //*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR reference front() const ETL_NOEXCEPT_IF(ETL_NOT_USING_EXCEPTIONS || ETL_NOT_CHECKING_EXTRA) ETL_NODISCARD ETL_CONSTEXPR reference front() const ETL_NOEXCEPT_IF(ETL_NOT_CHECKING_EXTRA)
{ {
#if ETL_USING_CPP11 && ETL_NOT_USING_CPP14 && ETL_USING_EXCEPTIONS && ETL_CHECKING_EXTRA #if ETL_USING_CPP11 && ETL_NOT_USING_CPP14 && ETL_USING_EXCEPTIONS && ETL_CHECKING_EXTRA
return size() > 0 ? *pbegin : throw(ETL_ERROR(span_out_of_range)); return size() > 0 ? *pbegin : throw(ETL_ERROR(span_out_of_range));
@ -1017,7 +1015,7 @@ namespace etl
//************************************************************************* //*************************************************************************
/// Returns a reference to the last element. /// Returns a reference to the last element.
//************************************************************************* //*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR reference back() const ETL_NOEXCEPT_IF(ETL_NOT_USING_EXCEPTIONS || ETL_NOT_CHECKING_EXTRA) ETL_NODISCARD ETL_CONSTEXPR reference back() const ETL_NOEXCEPT_IF(ETL_NOT_CHECKING_EXTRA)
{ {
#if ETL_USING_CPP11 && ETL_NOT_USING_CPP14 && ETL_USING_EXCEPTIONS && ETL_CHECKING_EXTRA #if ETL_USING_CPP11 && ETL_NOT_USING_CPP14 && ETL_USING_EXCEPTIONS && ETL_CHECKING_EXTRA
return size() > 0 ? *(pend - 1) : throw(ETL_ERROR(span_out_of_range)); return size() > 0 ? *(pend - 1) : throw(ETL_ERROR(span_out_of_range));
@ -1197,7 +1195,7 @@ namespace etl
/// span. /// span.
//************************************************************************* //*************************************************************************
template <size_t COUNT> template <size_t COUNT>
ETL_NODISCARD ETL_CONSTEXPR etl::span<element_type, COUNT> first() const ETL_NOEXCEPT_IF(ETL_NOT_USING_EXCEPTIONS || ETL_NOT_CHECKING_EXTRA) ETL_NODISCARD ETL_CONSTEXPR etl::span<element_type, COUNT> first() const ETL_NOEXCEPT_IF(ETL_NOT_CHECKING_EXTRA)
{ {
#if ETL_USING_CPP11 && ETL_NOT_USING_CPP14 && ETL_USING_EXCEPTIONS && ETL_CHECKING_EXTRA #if ETL_USING_CPP11 && ETL_NOT_USING_CPP14 && ETL_USING_EXCEPTIONS && ETL_CHECKING_EXTRA
return COUNT <= size() ? etl::span<element_type, COUNT>(pbegin, pbegin + COUNT) : throw(ETL_ERROR(span_out_of_range)); return COUNT <= size() ? etl::span<element_type, COUNT>(pbegin, pbegin + COUNT) : throw(ETL_ERROR(span_out_of_range));
@ -1212,8 +1210,7 @@ namespace etl
/// Obtains a span that is a view over the first count elements of this /// Obtains a span that is a view over the first count elements of this
/// span. /// span.
//************************************************************************* //*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR etl::span<element_type, etl::dynamic_extent> first(size_t count) const ETL_NODISCARD ETL_CONSTEXPR etl::span<element_type, etl::dynamic_extent> first(size_t count) const ETL_NOEXCEPT_IF(ETL_NOT_CHECKING_EXTRA)
ETL_NOEXCEPT_IF(ETL_NOT_USING_EXCEPTIONS || ETL_NOT_CHECKING_EXTRA)
{ {
#if ETL_USING_CPP11 && ETL_NOT_USING_CPP14 && ETL_USING_EXCEPTIONS && ETL_CHECKING_EXTRA #if ETL_USING_CPP11 && ETL_NOT_USING_CPP14 && ETL_USING_EXCEPTIONS && ETL_CHECKING_EXTRA
return count <= size() ? etl::span<element_type, etl::dynamic_extent>(pbegin, pbegin + count) : throw(ETL_ERROR(span_out_of_range)); return count <= size() ? etl::span<element_type, etl::dynamic_extent>(pbegin, pbegin + count) : throw(ETL_ERROR(span_out_of_range));
@ -1228,7 +1225,7 @@ namespace etl
/// Obtains a span that is a view over the last COUNT elements of this span. /// Obtains a span that is a view over the last COUNT elements of this span.
//************************************************************************* //*************************************************************************
template <size_t COUNT> template <size_t COUNT>
ETL_NODISCARD ETL_CONSTEXPR etl::span<element_type, COUNT> last() const ETL_NOEXCEPT_IF(ETL_NOT_USING_EXCEPTIONS || ETL_NOT_CHECKING_EXTRA) ETL_NODISCARD ETL_CONSTEXPR etl::span<element_type, COUNT> last() const ETL_NOEXCEPT_IF(ETL_NOT_CHECKING_EXTRA)
{ {
#if ETL_USING_CPP11 && ETL_NOT_USING_CPP14 && ETL_USING_EXCEPTIONS && ETL_CHECKING_EXTRA #if ETL_USING_CPP11 && ETL_NOT_USING_CPP14 && ETL_USING_EXCEPTIONS && ETL_CHECKING_EXTRA
return COUNT <= size() ? etl::span<element_type, COUNT>(pend - COUNT, pend) : throw(ETL_ERROR(span_out_of_range)); return COUNT <= size() ? etl::span<element_type, COUNT>(pend - COUNT, pend) : throw(ETL_ERROR(span_out_of_range));
@ -1242,8 +1239,7 @@ namespace etl
//************************************************************************* //*************************************************************************
/// Obtains a span that is a view over the last count elements of this span. /// Obtains a span that is a view over the last count elements of this span.
//************************************************************************* //*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR etl::span<element_type, etl::dynamic_extent> last(size_t count) const ETL_NODISCARD ETL_CONSTEXPR etl::span<element_type, etl::dynamic_extent> last(size_t count) const ETL_NOEXCEPT_IF(ETL_NOT_CHECKING_EXTRA)
ETL_NOEXCEPT_IF(ETL_NOT_USING_EXCEPTIONS || ETL_NOT_CHECKING_EXTRA)
{ {
#if ETL_USING_CPP11 && ETL_NOT_USING_CPP14 && ETL_USING_EXCEPTIONS && ETL_CHECKING_EXTRA #if ETL_USING_CPP11 && ETL_NOT_USING_CPP14 && ETL_USING_EXCEPTIONS && ETL_CHECKING_EXTRA
return count <= size() ? etl::span<element_type, etl::dynamic_extent>(pend - count, pend) : throw(ETL_ERROR(span_out_of_range)); return count <= size() ? etl::span<element_type, etl::dynamic_extent>(pend - count, pend) : throw(ETL_ERROR(span_out_of_range));
@ -1261,7 +1257,7 @@ namespace etl
//************************************************************************* //*************************************************************************
template <size_t OFFSET, size_t COUNT = etl::dynamic_extent> template <size_t OFFSET, size_t COUNT = etl::dynamic_extent>
ETL_NODISCARD ETL_CONSTEXPR etl::span< element_type, COUNT != etl::dynamic_extent ? COUNT : etl::dynamic_extent> subspan() const ETL_NODISCARD ETL_CONSTEXPR etl::span< element_type, COUNT != etl::dynamic_extent ? COUNT : etl::dynamic_extent> subspan() const
ETL_NOEXCEPT_IF(ETL_NOT_USING_EXCEPTIONS || ETL_NOT_CHECKING_EXTRA) ETL_NOEXCEPT_IF(ETL_NOT_CHECKING_EXTRA)
{ {
#if ETL_USING_CPP11 && ETL_NOT_USING_CPP14 && ETL_USING_EXCEPTIONS && ETL_CHECKING_EXTRA #if ETL_USING_CPP11 && ETL_NOT_USING_CPP14 && ETL_USING_EXCEPTIONS && ETL_CHECKING_EXTRA
return (OFFSET <= size()) && (COUNT != etl::dynamic_extent ? COUNT <= (size() - OFFSET) : true) return (OFFSET <= size()) && (COUNT != etl::dynamic_extent ? COUNT <= (size() - OFFSET) : true)
@ -1305,7 +1301,7 @@ namespace etl
/// elements of this span. /// elements of this span.
//************************************************************************* //*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR14 etl::span<element_type, etl::dynamic_extent> subspan(size_t offset, size_t count = etl::dynamic_extent) const ETL_NODISCARD ETL_CONSTEXPR14 etl::span<element_type, etl::dynamic_extent> subspan(size_t offset, size_t count = etl::dynamic_extent) const
ETL_NOEXCEPT_IF(ETL_NOT_USING_EXCEPTIONS || ETL_NOT_CHECKING_EXTRA) ETL_NOEXCEPT_IF(ETL_NOT_CHECKING_EXTRA)
{ {
ETL_ASSERT_CHECK_EXTRA(offset <= size(), ETL_ERROR(span_out_of_range)); ETL_ASSERT_CHECK_EXTRA(offset <= size(), ETL_ERROR(span_out_of_range));
ETL_ASSERT_CHECK_EXTRA(count != etl::dynamic_extent ? count <= (size() - offset) : true, ETL_ERROR(span_out_of_range)); ETL_ASSERT_CHECK_EXTRA(count != etl::dynamic_extent ? count <= (size() - offset) : true, ETL_ERROR(span_out_of_range));

View File

@ -355,7 +355,7 @@ namespace etl
/// If asserts or exceptions are enabled, throws an etl::string_view_bounds /// If asserts or exceptions are enabled, throws an etl::string_view_bounds
/// if the index is out of bounds. /// if the index is out of bounds.
//************************************************************************* //*************************************************************************
ETL_CONSTEXPR const_reference operator[](size_type i) const ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS || ETL_NOT_CHECKING_INDEX_OPERATOR) ETL_CONSTEXPR const_reference operator[](size_type i) const ETL_NOEXCEPT_EXPR(ETL_NOT_CHECKING_INDEX_OPERATOR)
{ {
#if ETL_USING_CPP11 && ETL_NOT_USING_CPP14 && ETL_USING_EXCEPTIONS && ETL_CHECKING_INDEX_OPERATOR #if ETL_USING_CPP11 && ETL_NOT_USING_CPP14 && ETL_USING_EXCEPTIONS && ETL_CHECKING_INDEX_OPERATOR
return i < size() ? mbegin[i] : throw(ETL_ERROR(string_view_bounds)); return i < size() ? mbegin[i] : throw(ETL_ERROR(string_view_bounds));

View File

@ -393,7 +393,7 @@ namespace etl
typename etl::enable_if<!etl::is_integral<TIterator>::value typename etl::enable_if<!etl::is_integral<TIterator>::value
&& etl::is_convertible<typename etl::iterator_traits<TIterator>::value_type, T>::value, && etl::is_convertible<typename etl::iterator_traits<TIterator>::value_type, T>::value,
typename etl::enable_if<!etl::is_integral<TIterator>::value, void>::type>::type typename etl::enable_if<!etl::is_integral<TIterator>::value, void>::type>::type
assign(TIterator first, TIterator last) ETL_NOEXCEPT_IF((etl::is_nothrow_copy_constructible<T>::value && ETL_NOT_USING_EXCEPTIONS)) assign(TIterator first, TIterator last)
{ {
#if ETL_USING_CPP11 #if ETL_USING_CPP11
ETL_STATIC_ASSERT((etl::is_same<typename etl::remove_cv<T>::type, ETL_STATIC_ASSERT((etl::is_same<typename etl::remove_cv<T>::type,
@ -2082,7 +2082,6 @@ namespace etl
/// Copy constructor. /// Copy constructor.
//************************************************************************* //*************************************************************************
vector_ext(const vector_ext& other, void* buffer, size_t max_size) vector_ext(const vector_ext& other, void* buffer, size_t max_size)
ETL_NOEXCEPT_IF((etl::is_nothrow_copy_constructible<T>::value && ETL_NOT_USING_EXCEPTIONS))
: etl::ivector<T>(reinterpret_cast<T*>(buffer), max_size) : etl::ivector<T>(reinterpret_cast<T*>(buffer), max_size)
{ {
if (&other != this) if (&other != this)
@ -2094,7 +2093,7 @@ namespace etl
//************************************************************************* //*************************************************************************
/// Assignment operator. /// Assignment operator.
//************************************************************************* //*************************************************************************
vector_ext& operator=(const vector_ext& rhs) ETL_NOEXCEPT_IF((etl::is_nothrow_copy_constructible<T>::value && ETL_NOT_USING_EXCEPTIONS)) vector_ext& operator=(const vector_ext& rhs)
{ {
if (&rhs != this) if (&rhs != this)
{ {
@ -2109,7 +2108,6 @@ namespace etl
/// Move constructor. /// Move constructor.
//************************************************************************* //*************************************************************************
vector_ext(vector_ext&& other, void* buffer, size_t max_size) vector_ext(vector_ext&& other, void* buffer, size_t max_size)
ETL_NOEXCEPT_IF((etl::is_nothrow_move_constructible<T>::value && ETL_NOT_USING_EXCEPTIONS))
: etl::ivector<T>(reinterpret_cast<T*>(buffer), max_size) : etl::ivector<T>(reinterpret_cast<T*>(buffer), max_size)
{ {
if (&other != this) if (&other != this)
@ -2123,7 +2121,7 @@ namespace etl
//************************************************************************* //*************************************************************************
/// Move assignment operator. /// Move assignment operator.
//************************************************************************* //*************************************************************************
vector_ext& operator=(vector_ext&& rhs) ETL_NOEXCEPT_IF((etl::is_nothrow_move_constructible<T>::value && ETL_NOT_USING_EXCEPTIONS)) vector_ext& operator=(vector_ext&& rhs)
{ {
if (&rhs != this) if (&rhs != this)
{ {