Skip to content

Commit

Permalink
Update base parsing with set IPADDRESS_NO_EXCEPTIONS
Browse files Browse the repository at this point in the history
  • Loading branch information
VladimirShaleev committed Jun 1, 2024
1 parent 5e6ef0c commit 94a3809
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions include/ipaddress/ip-address-base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,15 @@ class ip_address_base : public Base {
*/
template <typename T, size_t N>
IPADDRESS_NODISCARD_WHEN_NO_EXCEPTIONS static IPADDRESS_CONSTEXPR IPADDRESS_FORCE_INLINE ip_address_base parse(const T(&address)[N]) IPADDRESS_NOEXCEPT_WHEN_NO_EXCEPTIONS {
#ifdef IPADDRESS_NO_EXCEPTIONS
error_code err = error_code::no_error;
auto str = make_fixed_string(address, err);
if (err != error_code::no_error) {
return {};
}
#else
auto str = make_fixed_string(address);
#endif
return parse_string(str);
}

Expand Down
8 changes: 8 additions & 0 deletions include/ipaddress/ip-network-base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,15 @@ class ip_network_base : public Base {
*/
template <typename T, size_t N>
IPADDRESS_NODISCARD_WHEN_NO_EXCEPTIONS static IPADDRESS_CONSTEXPR IPADDRESS_FORCE_INLINE ip_network_base parse(const T(&address)[N], bool strict = true) IPADDRESS_NOEXCEPT_WHEN_NO_EXCEPTIONS {
#ifdef IPADDRESS_NO_EXCEPTIONS
error_code err = error_code::no_error;
auto str = make_fixed_string(address, err);
if (err != error_code::no_error) {
return {};
}
#else
auto str = make_fixed_string(address);
#endif
return parse_address_with_prefix(str, strict);
}

Expand Down

0 comments on commit 94a3809

Please sign in to comment.