@@ -9,6 +9,18 @@ extern "C" {
99
1010using i18n::phonenumbers::PhoneNumber;
1111
12+// libphonenumber versions < 8.6.0 do not define CountryCodeSource::UNSPECIFIED
13+// The value PN_UNSPECIFIED contains CountryCodeSource::UNSPECIFIED if it is
14+// defined, otherwise 0 (the value used in the newer versions).
15+template<typename T, typename = void>
16+struct check_UNSPECIFIED: std::integral_constant<T, static_cast<T>(0)>
17+{};
18+template<typename T>
19+struct check_UNSPECIFIED<T, void_t<decltype(T::UNSPECIFIED)>>:
20+ std::integral_constant<T, T::UNSPECIFIED>
21+{};
22+static constexpr auto PN_UNSPECIFIED = check_UNSPECIFIED<PhoneNumber::CountryCodeSource>::value;
23+
1224static PhoneNumber::CountryCodeSource marshal_country_code_source(country_code_source value)
1325{
1426 static_assert(is_same_enum<
@@ -20,7 +32,7 @@ static PhoneNumber::CountryCodeSource marshal_country_code_source(country_code_s
2032 FROM_DEFAULT_COUNTRY
2133 >,
2234 enum_values<PhoneNumber::CountryCodeSource,
23− PhoneNumber::UNSPECIFIED,
35+ PN_UNSPECIFIED,
2436 PhoneNumber::FROM_NUMBER_WITH_PLUS_SIGN,
2537 PhoneNumber::FROM_NUMBER_WITH_IDD,
2638 PhoneNumber::FROM_NUMBER_WITHOUT_PLUS_SIGN,