Skip to content

Commit 482542b

Browse files
vspefshsutter
andauthored
Add a conditional compilation directive to be compatible with C++26 (#1367)
* Add a conditional compilation directive to be compatible with C++26 * fix typo Signed-off-by: vspefs <[email protected]> * Tweak comment before merging --------- Signed-off-by: vspefs <[email protected]> Co-authored-by: Herb Sutter <[email protected]>
1 parent ec07cbc commit 482542b

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

Diff for: source/common.h

+4-6
Original file line numberDiff line numberDiff line change
@@ -580,12 +580,9 @@ auto print_with_thousands(T val)
580580
}
581581

582582

583-
// In keep trying to write string+string_view, and it ought to Just Work without
584-
// the current workarounds. Not having that is a minor impediment to using safe
585-
// and efficient string_views, which we should be encouraging. So for my own use
586-
// and to remove that minor impediment to writing safe and efficient code, I'm
587-
// just going to add this until we get P2591 in C++26(?) -- See: wg21.link/p2591
588-
//
583+
// Provide string+string_view if P2591 is not available.
584+
//
585+
#if __cpp_lib_string_view < 202403L
589586
template<class charT, class traits, class Allocator>
590587
[[nodiscard]] constexpr auto operator+(
591588
std::basic_string<charT, traits, Allocator> lhs,
@@ -605,6 +602,7 @@ template<class charT, class traits, class Allocator>
605602
{
606603
return rhs.insert(0, lhs);
607604
}
605+
#endif
608606

609607

610608
//-----------------------------------------------------------------------

0 commit comments

Comments
 (0)