Skip to content

Commit

Permalink
Add a conditional compilation directive to be compatible with C++26 (#…
Browse files Browse the repository at this point in the history
…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]>
  • Loading branch information
vspefs and hsutter authored Mar 1, 2025
1 parent ec07cbc commit 482542b
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions source/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -580,12 +580,9 @@ auto print_with_thousands(T val)
}


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


//-----------------------------------------------------------------------
Expand Down

0 comments on commit 482542b

Please sign in to comment.