Range formatter fix with a public trait is_container_adaptor

This commit is contained in:
Soumik15630m 2026-01-29 10:25:05 +05:30
parent 2f9bb5287f
commit 7e8bc4134f
2 changed files with 6 additions and 14 deletions

View File

@ -352,8 +352,7 @@ template <typename T, typename Char> struct is_range {
* that should be formatted by iterating over the underlying container.
* */
FMT_EXPORT
template <typename T> struct is_container_adaptor : std::true_type {};
namespace detail {
@ -774,11 +773,14 @@ template <typename Container> struct all {
};
} // namespace detail
FMT_EXPORT
template <typename T> struct is_container_adaptor: detail::is_container_adaptor_like<T> {};
template <typename T, typename Char>
struct formatter<
T, Char,
enable_if_t<conjunction<detail::is_container_adaptor_like<T>,
is_container_adaptor<T>,
enable_if_t<conjunction<is_container_adaptor<T>,
bool_constant<range_format_kind<T, Char>::value ==
range_format::disabled>>::value>>
: formatter<detail::all<typename T::container_type>, Char> {

View File

@ -17,10 +17,6 @@
#include <utility>
#include <vector>
#include "fmt/base.h"
#include "fmt/ranges.h"
#include "posix-mock.h"
#if FMT_CPLUSPLUS > 201703L && FMT_HAS_INCLUDE(<ranges>)
# include <ranges>
#endif
@ -807,16 +803,10 @@ namespace test_detail {
struct partial_opt_out_wrapper {
using container_type = std::vector<T>;
std::vector<T> c = {1, 2, 3};
typename std::vector<T>::const_iterator begin() const { return c.begin(); }
typename std::vector<T>::const_iterator end() const { return c.end(); }
};
} // namespace test_detail
namespace fmt {
template <typename T>
struct is_range<test_detail::partial_opt_out_wrapper<T>, char> : std::false_type {};
template <typename T>
struct is_container_adaptor<test_detail::partial_opt_out_wrapper<T>> : std::false_type {};