Commit fb5a4f6
ARROW-15520: [C++] Qualify
As explained in ARROW-15520, these unqualified calls to `format()` are ambiguous in the C++20 Standard.
The `using`-declaration `using arrow_vendored::date::format;` makes the compiler consider the desired overload, but it doesn't automatically win. Argument-Dependent Lookup also considers `std::format()` because the arguments are `std::chrono::duration` types (and `<chrono>` includes `<format>` in MSVC's implementation). A very recent change to `std::format()`'s signature in a C++20 Defect Report makes it an equally good match as the desired `arrow_vendored::date::format()` overload, so the compiler emits an ambiguity error.
The fix is simple, although slightly verbose - the code simply needs to explicitly qualify each call, in order to defend against Argument-Dependent Lookup. The fix is also perfectly backwards-compatible (i.e. it works in previous Standard versions, and with all other platforms).
(Also as mentioned in ARROW-15520, although this requires building Apache Arrow with non-default settings to use the latest C++ Standard version, this change is good for future-proofing and will make it easier for the MSVC team to continue validation that prevents toolset regressions that could affect Apache Arrow and other projects.)
Closes #12317 from StephanTLavavej/cxx20-format
Lead-authored-by: Stephan T. Lavavej <stl@microsoft.com>
Co-authored-by: Antoine Pitrou <pitrou@free.fr>
Co-authored-by: Stephan T. Lavavej <stl@nuwen.net>
Signed-off-by: Antoine Pitrou <antoine@python.org>arrow_vendored::date::format() for C++20 compatibility1 parent 56386a4 commit fb5a4f6
1 file changed
+12
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
639 | 639 | | |
640 | 640 | | |
641 | 641 | | |
642 | | - | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
643 | 645 | | |
644 | 646 | | |
645 | 647 | | |
646 | 648 | | |
647 | 649 | | |
648 | | - | |
| 650 | + | |
649 | 651 | | |
650 | 652 | | |
651 | 653 | | |
652 | | - | |
| 654 | + | |
653 | 655 | | |
654 | 656 | | |
655 | | - | |
| 657 | + | |
656 | 658 | | |
657 | 659 | | |
658 | | - | |
| 660 | + | |
659 | 661 | | |
660 | 662 | | |
661 | | - | |
| 663 | + | |
662 | 664 | | |
663 | 665 | | |
664 | 666 | | |
665 | 667 | | |
666 | 668 | | |
667 | 669 | | |
668 | | - | |
| 670 | + | |
669 | 671 | | |
670 | 672 | | |
671 | | - | |
| 673 | + | |
672 | 674 | | |
673 | 675 | | |
674 | | - | |
| 676 | + | |
675 | 677 | | |
676 | 678 | | |
677 | | - | |
| 679 | + | |
678 | 680 | | |
679 | 681 | | |
680 | 682 | | |
| |||
0 commit comments