Skip to content

Commit

Permalink
Add IPADDRESS_CONSTEVAL
Browse files Browse the repository at this point in the history
  • Loading branch information
VladimirShaleev committed Feb 24, 2024
1 parent 9c2bdfe commit 0b1eca3
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 11 deletions.
1 change: 1 addition & 0 deletions doc/Doxyfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -2472,6 +2472,7 @@ PREDEFINED = "IPADDRESS_FORCE_INLINE=\"inline\"" \
"IPADDRESS_CONSTEXPR=\"constexpr\"" \
"IPADDRESS_CONSTEXPR_14=\"constexpr\"" \
"IPADDRESS_CONSTEXPR_17=\"constexpr\"" \
"IPADDRESS_CONSTEVAL=\"consteval\"" \
"IPADDRESS_CPP_VERSION=\"20\"" \
"IPADDRESS_NONTYPE_TEMPLATE_PARAMETER=\"1\"" \
"IPADDRESS_IPV6_SCOPE_MAX_LENGTH=IPADDRESS_IPV6_SCOPE_MAX_LENGTH" \
Expand Down
6 changes: 6 additions & 0 deletions include/ipaddress/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@
# error ipaddress needs at least C++ standard version 11
#endif

#if __GNUC__ <= 9 && !defined(__llvm__) && !defined(__INTEL_COMPILER)
# define IPADDRESS_CONSTEVAL IPADDRESS_CONSTEXPR
#else
# define IPADDRESS_CONSTEVAL consteval
#endif

#if defined(_MSC_VER) && (_MSC_VER <= 1800)
# define IPADDRESS_NOEXCEPT
#else
Expand Down
2 changes: 1 addition & 1 deletion include/ipaddress/ip-address-base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class ip_address_base : public Base {
* @remark If parsing fails, an error will be raised at compile time.
*/
template <fixed_string FixedString>
IPADDRESS_NODISCARD static consteval IPADDRESS_FORCE_INLINE ip_address_base<Base> parse() IPADDRESS_NOEXCEPT {
IPADDRESS_NODISCARD static IPADDRESS_CONSTEVAL IPADDRESS_FORCE_INLINE ip_address_base<Base> parse() IPADDRESS_NOEXCEPT {
constexpr auto str = FixedString;
auto code = error_code::NO_ERROR;
auto index = 0;
Expand Down
4 changes: 2 additions & 2 deletions include/ipaddress/ip-any-address.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ class ip_address {
* @remark If parsing fails, an error will be raised at compile time.
*/
template <fixed_string FixedString>
IPADDRESS_NODISCARD static consteval IPADDRESS_FORCE_INLINE ip_address parse() IPADDRESS_NOEXCEPT {
IPADDRESS_NODISCARD static IPADDRESS_CONSTEVAL IPADDRESS_FORCE_INLINE ip_address parse() IPADDRESS_NOEXCEPT {
constexpr auto str = FixedString;
auto code = error_code::NO_ERROR;

Expand Down Expand Up @@ -1350,7 +1350,7 @@ class ip_address {
* @return An ip_address object parsed from the fixed string.
*/
template <fixed_string FixedString>
IPADDRESS_NODISCARD consteval IPADDRESS_FORCE_INLINE ip_address operator""_ip() IPADDRESS_NOEXCEPT {
IPADDRESS_NODISCARD IPADDRESS_CONSTEVAL IPADDRESS_FORCE_INLINE ip_address operator""_ip() IPADDRESS_NOEXCEPT {
return ip_address::parse<FixedString>();
}

Expand Down
4 changes: 2 additions & 2 deletions include/ipaddress/ip-any-network.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ class ip_network {
#ifdef IPADDRESS_NONTYPE_TEMPLATE_PARAMETER

template <fixed_string FixedString, bool Strict = true>
IPADDRESS_NODISCARD static consteval IPADDRESS_FORCE_INLINE ip_network parse() IPADDRESS_NOEXCEPT {
IPADDRESS_NODISCARD static IPADDRESS_CONSTEVAL IPADDRESS_FORCE_INLINE ip_network parse() IPADDRESS_NOEXCEPT {
constexpr auto str = FixedString;
auto code = error_code::NO_ERROR;

Expand Down Expand Up @@ -529,7 +529,7 @@ class ip_network {
#ifdef IPADDRESS_NONTYPE_TEMPLATE_PARAMETER

template <fixed_string FixedString>
IPADDRESS_NODISCARD consteval IPADDRESS_FORCE_INLINE ip_network operator""_net() IPADDRESS_NOEXCEPT {
IPADDRESS_NODISCARD IPADDRESS_CONSTEVAL IPADDRESS_FORCE_INLINE ip_network operator""_net() IPADDRESS_NOEXCEPT {
return ip_network::parse<FixedString>();
}

Expand Down
2 changes: 1 addition & 1 deletion include/ipaddress/ip-network-base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class ip_network_base : public Base {
* @return A consteval ip network object representing the parsed network.
*/
template <fixed_string FixedString, bool Strict = true>
IPADDRESS_NODISCARD static consteval ip_network_base parse() IPADDRESS_NOEXCEPT {
IPADDRESS_NODISCARD static IPADDRESS_CONSTEVAL ip_network_base parse() IPADDRESS_NOEXCEPT {
constexpr auto str = FixedString;
auto code = error_code::NO_ERROR;
auto index = 0;
Expand Down
4 changes: 2 additions & 2 deletions include/ipaddress/ipv4-address.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ using ipv4_address = ip_address_base<ipv4_address_base>;
* @return An ipv4_address object parsed from the fixed string.
*/
template <fixed_string FixedString>
IPADDRESS_NODISCARD consteval IPADDRESS_FORCE_INLINE ipv4_address operator""_ipv4() IPADDRESS_NOEXCEPT {
IPADDRESS_NODISCARD IPADDRESS_CONSTEVAL IPADDRESS_FORCE_INLINE ipv4_address operator""_ipv4() IPADDRESS_NOEXCEPT {
return ipv4_address::parse<FixedString>();
}

Expand All @@ -134,7 +134,7 @@ using ipv4_address = ip_address_base<ipv4_address_base>;
* @param[in] value An unsigned long long integer representing the IPv4 address in *host byte order*.
* @return An ipv4_address object created from the integer.
*/
IPADDRESS_NODISCARD consteval IPADDRESS_FORCE_INLINE ipv4_address operator""_ipv4(unsigned long long value) IPADDRESS_NOEXCEPT {
IPADDRESS_NODISCARD IPADDRESS_CONSTEVAL IPADDRESS_FORCE_INLINE ipv4_address operator""_ipv4(unsigned long long value) IPADDRESS_NOEXCEPT {
assert(value <= ipv4_address::base_all_ones && "literal integer is too long");
return ipv4_address::from_uint(uint32_t(value));
}
Expand Down
2 changes: 1 addition & 1 deletion include/ipaddress/ipv4-network.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ using ipv4_network = ip_network_base<ipv4_network_base>;
#ifdef IPADDRESS_NONTYPE_TEMPLATE_PARAMETER

template <fixed_string FixedString>
IPADDRESS_NODISCARD consteval IPADDRESS_FORCE_INLINE ipv4_network operator""_ipv4_net() IPADDRESS_NOEXCEPT {
IPADDRESS_NODISCARD IPADDRESS_CONSTEVAL IPADDRESS_FORCE_INLINE ipv4_network operator""_ipv4_net() IPADDRESS_NOEXCEPT {
return ipv4_network::parse<FixedString>();
}

Expand Down
2 changes: 1 addition & 1 deletion include/ipaddress/ipv6-address.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,7 @@ using ipv6_address = ip_address_base<ipv6_address_base>;
* @return An ipv6_address object parsed from the fixed string.
*/
template <fixed_string FixedString>
IPADDRESS_NODISCARD consteval IPADDRESS_FORCE_INLINE ipv6_address operator""_ipv6() IPADDRESS_NOEXCEPT {
IPADDRESS_NODISCARD IPADDRESS_CONSTEVAL IPADDRESS_FORCE_INLINE ipv6_address operator""_ipv6() IPADDRESS_NOEXCEPT {
return ipv6_address::parse<FixedString>();
}

Expand Down
2 changes: 1 addition & 1 deletion include/ipaddress/ipv6-network.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ using ipv6_network = ip_network_base<ipv6_network_base>;
#ifdef IPADDRESS_NONTYPE_TEMPLATE_PARAMETER

template <fixed_string FixedString>
IPADDRESS_NODISCARD consteval IPADDRESS_FORCE_INLINE ipv6_network operator""_ipv6_net() IPADDRESS_NOEXCEPT {
IPADDRESS_NODISCARD IPADDRESS_CONSTEVAL IPADDRESS_FORCE_INLINE ipv6_network operator""_ipv6_net() IPADDRESS_NOEXCEPT {
return ipv6_network::parse<FixedString>();
}

Expand Down

0 comments on commit 0b1eca3

Please sign in to comment.