Commit Graph

87 Commits

Author SHA1 Message Date
Justin Riddell
fc723fd6c7
Fix regression in #3710 (#3968)
Regression introduced in 11f2f30
Already have a test for this, but needed to make __cpp_lib_ranges
smaller to enable it
2024-05-23 12:39:11 -07:00
Justin Riddell
b81761068b
Check range_begin is dereferenceable (#3964)
Fixes issue #3839
An Eigen 3.4 2x2 matrix has a begin member function that returns void
Be more strict checking that the result of calling *begin() is valid
See input_or_output_iterator concept notes about void
2024-05-20 16:11:07 -07:00
Victor Zverovich
75e892420e Minor cleanup 2024-05-16 10:45:23 -07:00
Justin Riddell
8e728044f6
Fix format_as for non-const begin/end views (#3955)
base::format does not accept rvalues, using the result of format_as
directly means it is passed one. Doesn't matter for ranges with a const
begin and end, but filter_view caches, so it only has mutable begin/end.
Use auto&& to avoid copy if format_as returns const ref
2024-05-13 09:35:55 -07:00
Victor Zverovich
7d6ae972b9 Cleanup unicode checks 2024-05-11 19:43:46 -07:00
Victor Zverovich
d2473b7b73 Simplify join_view formatter 2024-05-08 15:42:49 -07:00
Justin Riddell
10508a30ec
Enable fmt::join for uncopyable iterators (#3946)
If iterator not copyable mutate the underlying iterator
Notably std::ranges::basic_istream_view::__iterator
Addresses issue (#3802)
2024-05-05 15:44:23 -07:00
Victor Zverovich
16cec4f591 Make the map formatter correctly handle elements with custom formatters 2024-05-04 10:59:16 -07:00
Victor Zverovich
400f6a8ee2 Dedup ADL begin/end lookup 2024-04-22 16:09:07 -07:00
js324
0861db500f
Support character range formatting (#3863) 2024-03-07 10:51:46 -08:00
Beat Bolli
e1832bcf00
Consider ADL begin() and end() when joining ranges (#3824)
Closes #3813

Signed-off-by: Beat Bolli <dev@drbeat.li>
2024-01-22 07:39:33 -08:00
Victor Zverovich
d0963d4823 Make ranges only depend on fmt/base.h 2024-01-13 09:54:19 -08:00
Victor Zverovich
971f7ae768 Minor cleanup 2024-01-10 16:43:00 -08:00
Tristan Brindle
2595bf57b3 Fix formatting of ranges with begin()&/end()&
C++20 allows ranges to have lvalue-qualified begin() and end() member functions. fmt correctly handles this if begin() and end() are additionally const-qualifed (i.e. begin() const&), but not in the non-const case. For example:

https://godbolt.org/z/YfxaYz5r7

This patch fixes fmt's range detection to handle this case by testing calls to detail::ranges_begin()/end() with an lvalue T&, matching the behaviour in the const case.
2024-01-10 12:22:53 -08:00
Victor Zverovich
50565f9853 Move misplaced join overloads to fmt/ranges.h 2024-01-01 16:28:59 -08:00
Victor Zverovich
6f9a816786 Enable test 2023-12-23 10:14:27 -08:00
Victor Zverovich
e7875ae0fa Fix formatting of some nested ranges 2023-12-23 09:35:32 -08:00
Victor Zverovich
3eb3aef575 Fix handling of set_debug_format 2023-12-23 08:32:36 -08:00
Victor Zverovich
19276d7325 Fix an inconsistentcy between to_string and format 2023-10-28 08:05:11 -07:00
Victor Zverovich
ca608547e5 Workaround a C++11 issue 2023-09-04 10:07:14 -07:00
Victor Zverovich
a79a979828 Cleanup ranges test 2023-09-04 09:19:40 -07:00
Victor Zverovich
457bb6a98f Merge the copyright comment since there are many contributors 2023-09-04 09:09:01 -07:00
5chmidti
8a4bec5cf5
fix ambiguous formatter lookup for flat_set (#3561) 2023-07-31 09:26:33 -07:00
Victor Zverovich
e0748e61dd Fix recursion check in range formatting 2023-03-04 08:20:32 -08:00
Victor Zverovich
76f520835f Call element parse in tuple parse 2023-02-20 12:54:20 -08:00
Victor Zverovich
1741e90dec Always call parse in range formatter 2023-02-18 09:58:37 -08:00
Victor Zverovich
655046d24f Fix container adaptor formatting 2023-02-10 09:45:37 -08:00
Shawn Zhong
581c6292c9
Add formatters for container adapters (#3279) 2023-02-08 17:25:41 -08:00
Barry Revzin
05e3a9233a
Allowing formatting non-copyable ranges. (#3290) 2023-01-27 12:29:57 -08:00
Victor Zverovich
9e4a54fa6e Disable remaining implicit conversions 2023-01-03 12:08:42 -08:00
Barry Revzin
66d71a1b35
Fixing formatting of range of range of char. (#3158) 2022-11-02 11:04:54 -07:00
Victor Zverovich
4a8e2949bb Fix formatting of ranges of code unit types
Thanks Nicole Mazzuca.
2022-08-26 13:48:58 -07:00
Vladislav Shchapov
489dabbd31
Fix decoder on broken utf8 sequences. (#3044)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>

Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-08-24 07:13:27 -07:00
Barry Revzin
0b2862a1e4
Range formatter (#2983)
* Implement range_formatter and format_kind

* Attempted gcc 4.8 fix

* gcc 4.8 interprets inaccessible as a hard error (instead of... not available)

* Attempting to delete set_debug_format.

* clang-format

* Different implementation of FMT_STATICALLY_WIDEN

* Renaming copy_str_range to copy_str.

* I guess I need a definition

* Forgot to delete these.

* Other PR comments.
2022-07-29 13:55:16 -07:00
Barry Revzin
92d36e82c4
The n specifier for ranges (#2981)
* The n specifier for ranges.

* Flipping flag polarity.
2022-07-12 10:08:38 -07:00
Victor Zverovich
0c06c81da8 Deprecated implicit conversion of enums to ints for consistency with scoped enums 2022-07-03 09:02:22 -07:00
jehelset
5682338891
Fix is_formattable for tuple-like types. (#2940) 2022-06-19 08:25:58 -07:00
Victor Zverovich
c83a5d42bb FMT_MSC_VER -> FMT_MSC_VERSION 2022-05-29 15:39:08 -07:00
Vladislav Shchapov
1f9eae7e31 Add xchar support for write_escaped_string.
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-05-27 08:36:38 -07:00
Riccardo Brugo
a8fe8becf4
Fix compilation error for ranges with ADL begin/end (#2807)
* Use `range_begin`/`end` to get formatted range iterators

* Add test for adl `begin`/`end`

* Apply clang-format

* Simplify tests
2022-03-11 11:36:39 -08:00
Barry Revzin
0cef1f819e
Fixing formatting of certain kinds of ranges of ranges. (#2787)
* Fixing formatting of certain kinds of ranges of ranges.

* Renaming const_range to range_type.
2022-03-04 16:21:00 -08:00
Victor Zverovich
8a21e328b8 Remove problematic constructibility check 2022-02-04 12:20:02 -08:00
Barry Revzin
6e0f1399d7
Supporting nested format specs for ranges. (#2673)
* Supporting nested format specs for ranges.

* I dedicate this commit to Eric Niebler.

* clang-format

* PR comments.

* throw -> FMT_THROW

* Need to map every element too.

* Clarifying uncvref_type

* Trying to add a workaround for MSVC.
2022-01-08 09:48:26 -08:00
Victor Zverovich
796662a612 Escape range items convertible to std::string_view 2021-12-27 09:38:06 -08:00
Victor Zverovich
c882790a2e Add a set formatter 2021-12-18 07:35:40 -08:00
Victor Zverovich
121002d700 Add a map formatter 2021-12-18 07:12:53 -08:00
Victor Zverovich
fd62fba985 Don't convert scoped enums to integers 2021-12-09 12:09:33 -08:00
Barry Revzin
7aca36bca4
Extending fmt::join to support C++20-only ranges. (#2549) 2021-10-16 10:02:03 -07:00
Victor Zverovich
2fe94ad7e3 Make specifiers support in tuple_join an opt-in 2021-09-05 07:34:06 -07:00
Victor Zverovich
60cd5ea3f2 Add support for more formattable types in ranges 2021-09-03 14:55:41 -07:00