Skip to content

Commit

Permalink
fix: rename typename U to typename UT to avoid cpprest conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Oct 2, 2024
1 parent c90bc91 commit 98af87b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 20 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ build/
cmake_install.cmake
fmt-*.cmake
fmt.pc
.gradle/
10 changes: 5 additions & 5 deletions include/fmt/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -1088,16 +1088,16 @@ struct use_format_as_member<
T, bool_constant<std::is_arithmetic<format_as_member_result<T>>::value>>
: std::true_type {};

template <typename T, typename U = remove_const_t<T>>
template <typename T, typename UT = remove_const_t<T>>
using use_formatter =
bool_constant<(std::is_class<T>::value || std::is_enum<T>::value ||
std::is_union<T>::value || std::is_array<T>::value) &&
!has_to_string_view<T>::value && !is_named_arg<T>::value &&
!use_format_as<T>::value && !use_format_as_member<T>::value>;

template <typename Char, typename T, typename U = remove_const_t<T>>
template <typename Char, typename T, typename UT = remove_const_t<T>>
auto has_formatter_impl(T* p, buffered_context<Char>* ctx = nullptr)
-> decltype(formatter<U, Char>().format(*p, *ctx), std::true_type());
-> decltype(formatter<UT, Char>().format(*p, *ctx), std::true_type());
template <typename Char> auto has_formatter_impl(...) -> std::false_type;

// T can be const-qualified to check if it is const-formattable.
Expand Down Expand Up @@ -1764,14 +1764,14 @@ template <typename T> class buffer {
}

/// Appends data to the end of the buffer.
template <typename U>
template <typename UT>
// Workaround for MSVC2019 to fix error C2893: Failed to specialize function
// template 'void fmt::v11::detail::buffer<T>::append(const U *,const U *)'.
#if !FMT_MSC_VERSION || FMT_MSC_VERSION >= 1940
FMT_CONSTEXPR20
#endif
void
append(const U* begin, const U* end) {
append(const UT* begin, const UT* end) {
while (begin != end) {
auto count = to_unsigned(end - begin);
try_reserve(size_ + count);
Expand Down
12 changes: 6 additions & 6 deletions include/fmt/printf.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,10 @@ template <typename T, typename Context> class arg_converter {
if (type_ != 's') operator()<bool>(value);
}

template <typename U, FMT_ENABLE_IF(std::is_integral<U>::value)>
void operator()(U value) {
template <typename UT, FMT_ENABLE_IF(std::is_integral<UT>::value)>
void operator()(UT value) {
bool is_signed = type_ == 'd' || type_ == 'i';
using target_type = conditional_t<std::is_same<T, void>::value, U, T>;
using target_type = conditional_t<std::is_same<T, void>::value, UT, T>;
if (const_check(sizeof(target_type) <= sizeof(int))) {
// Extra casts are used to silence warnings.
using unsigned_type = typename make_unsigned_or_bool<target_type>::type;
Expand All @@ -157,12 +157,12 @@ template <typename T, typename Context> class arg_converter {
if (is_signed)
arg_ = static_cast<long long>(value);
else
arg_ = static_cast<typename make_unsigned_or_bool<U>::type>(value);
arg_ = static_cast<typename make_unsigned_or_bool<UT>::type>(value);
}
}

template <typename U, FMT_ENABLE_IF(!std::is_integral<U>::value)>
void operator()(U) {} // No conversion needed for non-integral types.
template <typename UT, FMT_ENABLE_IF(!std::is_integral<UT>::value)>
void operator()(UT) {} // No conversion needed for non-integral types.
};

// Converts an integer argument to T for printf, if T is an integral type.
Expand Down
18 changes: 9 additions & 9 deletions include/fmt/ranges.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ enum class range_format { disabled, map, set, sequence, string, debug_string };
namespace detail {

template <typename T> class is_map {
template <typename U> static auto check(U*) -> typename U::mapped_type;
template <typename UT> static auto check(UT*) -> typename UT::mapped_type;
template <typename> static void check(...);

public:
Expand All @@ -36,7 +36,7 @@ template <typename T> class is_map {
};

template <typename T> class is_set {
template <typename U> static auto check(U*) -> typename U::key_type;
template <typename UT> static auto check(UT*) -> typename UT::key_type;
template <typename> static void check(...);

public:
Expand Down Expand Up @@ -115,8 +115,8 @@ struct is_range_<T, void>

// tuple_size and tuple_element check.
template <typename T> class is_tuple_like_ {
template <typename U, typename V = typename std::remove_cv<U>::type>
static auto check(U* p) -> decltype(std::tuple_size<V>::value, 0);
template <typename UT, typename VT = typename std::remove_cv<UT>::type>
static auto check(UT* p) -> decltype(std::tuple_size<VT>::value, 0);
template <typename> static void check(...);

public:
Expand Down Expand Up @@ -388,8 +388,8 @@ struct range_formatter<
detail::string_literal<Char, ']'>{};
bool is_debug = false;

template <typename Output, typename It, typename Sentinel, typename U = T,
FMT_ENABLE_IF(std::is_same<U, Char>::value)>
template <typename Output, typename It, typename Sentinel, typename UT = T,
FMT_ENABLE_IF(std::is_same<UT, Char>::value)>
auto write_debug_string(Output& out, It it, Sentinel end) const -> Output {
auto buf = basic_memory_buffer<Char>();
for (; it != end; ++it) buf.push_back(*it);
Expand All @@ -399,8 +399,8 @@ struct range_formatter<
out, basic_string_view<Char>(buf.data(), buf.size()), specs);
}

template <typename Output, typename It, typename Sentinel, typename U = T,
FMT_ENABLE_IF(!std::is_same<U, Char>::value)>
template <typename Output, typename It, typename Sentinel, typename UT = T,
FMT_ENABLE_IF(!std::is_same<UT, Char>::value)>
auto write_debug_string(Output& out, It, Sentinel) const -> Output {
return out;
}
Expand Down Expand Up @@ -780,7 +780,7 @@ namespace detail {
// Check if T has an interface like a container adaptor (e.g. std::stack,
// std::queue, std::priority_queue).
template <typename T> class is_container_adaptor_like {
template <typename U> static auto check(U* p) -> typename U::container_type;
template <typename UT> static auto check(UT* p) -> typename UT::container_type;
template <typename> static void check(...);

public:
Expand Down

0 comments on commit 98af87b

Please sign in to comment.