Skip to content

Commit

Permalink
Fix compile GCC 7 and 8
Browse files Browse the repository at this point in the history
  • Loading branch information
VladimirShaleev committed Feb 24, 2024
1 parent a2c0d68 commit 2b02406
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
17 changes: 9 additions & 8 deletions include/ipaddress/byte-array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,13 @@ struct byte_array {
IPADDRESS_NODISCARD_WHEN_NO_EXCEPTIONS IPADDRESS_CONSTEXPR IPADDRESS_FORCE_INLINE reference at(size_t n) IPADDRESS_NOEXCEPT_WHEN_NO_EXCEPTIONS {
if (n >= 0 && n < N) {
return _data[n];
} else {
#ifdef IPADDRESS_NO_EXCEPTIONS
return *_data;
#else
throw std::out_of_range("index out of array");
#endif
}
#ifdef IPADDRESS_NO_EXCEPTIONS
return *_data;
#else
throw std::out_of_range("index out of array");
#endif
}

/**
Expand All @@ -194,13 +195,13 @@ struct byte_array {
* @throw std::out_of_range When going beyond the bounds of the array.
*/
IPADDRESS_NODISCARD_WHEN_NO_EXCEPTIONS IPADDRESS_CONSTEXPR IPADDRESS_FORCE_INLINE const_reference at(size_t n) const IPADDRESS_NOEXCEPT_WHEN_NO_EXCEPTIONS {
if (n >= 0 && n < N) {
//if (n >= 0 && n < N) {
return _data[n];
}
//}
#ifdef IPADDRESS_NO_EXCEPTIONS
return *_data;
#else
throw std::out_of_range("index out of array");
//throw std::out_of_range("index out of array");
#endif
}

Expand Down
11 changes: 6 additions & 5 deletions include/ipaddress/fixed-string.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,12 +257,13 @@ struct fixed_string {
IPADDRESS_NODISCARD_WHEN_NO_EXCEPTIONS IPADDRESS_CONSTEXPR IPADDRESS_FORCE_INLINE const_reference at(size_t n) const IPADDRESS_NOEXCEPT_WHEN_NO_EXCEPTIONS {
if (n >= 0 && n < N) {
return _data[n];
} else {
#ifdef IPADDRESS_NO_EXCEPTIONS
return *_data;
#else
throw std::out_of_range("index out of array");
#endif
}
#ifdef IPADDRESS_NO_EXCEPTIONS
return *_data;
#else
throw std::out_of_range("index out of array");
#endif
}

/**
Expand Down

0 comments on commit 2b02406

Please sign in to comment.