git.iko.soy/typeable/libphonenumber
on main help sign in
Support libphonenumber 7.1.0
commitdad2ec7d7ac7343e2da8df53bb232244516cb9f0 authormniip <mniip@mniip.com> dateThu 30 Mar 2023, 14:59 (4 years ago) parent94292f6
2 files changed+20−1
cxxbits/c_phonenumber.cpp+13−1 include/common.h+7
cxxbits/c_phonenumber.cpp+13−1
@@ -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,
include/common.h+7
@@ -50,6 +50,13 @@ struct is_same_enum<enum_values<T, TVals...>, enum_values<S, SVals...>>:
5050 >::value>
5151{};
5252
53+// std::void_t for compilers that don't have it
54+template<typename T>
55+struct make_void { using type = void; };
56+
57+template<typename T>
58+using void_t = typename make_void<T>::type;
59+
5360inline void unmarshal_string_size(std::string const &string, char *&c_string, size_t &c_string_size)
5461{
5562 c_string_size = string.size();