mirror of
https://github.com/fmtlib/fmt.git
synced 2026-02-11 04:39:58 +08:00
Range formatter fix with a public trait is_container_adaptor
This commit is contained in:
parent
2f9bb5287f
commit
7e8bc4134f
@ -352,8 +352,7 @@ template <typename T, typename Char> struct is_range {
|
|||||||
* that should be formatted by iterating over the underlying container.
|
* that should be formatted by iterating over the underlying container.
|
||||||
* */
|
* */
|
||||||
|
|
||||||
FMT_EXPORT
|
|
||||||
template <typename T> struct is_container_adaptor : std::true_type {};
|
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
@ -774,11 +773,14 @@ template <typename Container> struct all {
|
|||||||
};
|
};
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
|
FMT_EXPORT
|
||||||
|
template <typename T> struct is_container_adaptor: detail::is_container_adaptor_like<T> {};
|
||||||
|
|
||||||
|
|
||||||
template <typename T, typename Char>
|
template <typename T, typename Char>
|
||||||
struct formatter<
|
struct formatter<
|
||||||
T, Char,
|
T, Char,
|
||||||
enable_if_t<conjunction<detail::is_container_adaptor_like<T>,
|
enable_if_t<conjunction<is_container_adaptor<T>,
|
||||||
is_container_adaptor<T>,
|
|
||||||
bool_constant<range_format_kind<T, Char>::value ==
|
bool_constant<range_format_kind<T, Char>::value ==
|
||||||
range_format::disabled>>::value>>
|
range_format::disabled>>::value>>
|
||||||
: formatter<detail::all<typename T::container_type>, Char> {
|
: formatter<detail::all<typename T::container_type>, Char> {
|
||||||
|
|||||||
@ -17,10 +17,6 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "fmt/base.h"
|
|
||||||
#include "fmt/ranges.h"
|
|
||||||
#include "posix-mock.h"
|
|
||||||
|
|
||||||
#if FMT_CPLUSPLUS > 201703L && FMT_HAS_INCLUDE(<ranges>)
|
#if FMT_CPLUSPLUS > 201703L && FMT_HAS_INCLUDE(<ranges>)
|
||||||
# include <ranges>
|
# include <ranges>
|
||||||
#endif
|
#endif
|
||||||
@ -807,16 +803,10 @@ namespace test_detail {
|
|||||||
struct partial_opt_out_wrapper {
|
struct partial_opt_out_wrapper {
|
||||||
using container_type = std::vector<T>;
|
using container_type = std::vector<T>;
|
||||||
std::vector<T> c = {1, 2, 3};
|
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 test_detail
|
||||||
|
|
||||||
namespace fmt {
|
namespace fmt {
|
||||||
template <typename T>
|
|
||||||
struct is_range<test_detail::partial_opt_out_wrapper<T>, char> : std::false_type {};
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct is_container_adaptor<test_detail::partial_opt_out_wrapper<T>> : std::false_type {};
|
struct is_container_adaptor<test_detail::partial_opt_out_wrapper<T>> : std::false_type {};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user