mirror of
https://github.com/fmtlib/fmt.git
synced 2026-08-03 20:14:20 +02:00
Fix ambiguous formatter<std::optional<T>> between fmt/std.h and fmt/ranges.h on C++26 (P3168R2) (#4761)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
This commit is contained in:
committed by
GitHub
parent
5a9a184448
commit
9cb8c0f92b
@@ -271,6 +271,23 @@ TEST(ranges_test, disabled_range_formatting_of_path) {
|
||||
fmt::range_format::disabled);
|
||||
}
|
||||
|
||||
template <typename T> struct optional_like {
|
||||
auto begin() const -> const T*;
|
||||
auto end() const -> const T*;
|
||||
|
||||
bool has_value() const noexcept;
|
||||
T& value() &;
|
||||
const T& value() const&;
|
||||
T&& value() &&;
|
||||
const T&& value() const&&;
|
||||
};
|
||||
|
||||
TEST(ranges_test, disabled_range_formatting_of_optional) {
|
||||
// (C++26) Has a range support for std::optional.
|
||||
EXPECT_EQ((fmt::range_format_kind<optional_like<int>, char>::value),
|
||||
fmt::range_format::disabled);
|
||||
}
|
||||
|
||||
struct vector_string : std::vector<char> {
|
||||
using base = std::vector<char>;
|
||||
using base::base;
|
||||
|
||||
Reference in New Issue
Block a user