|
4 | 4 | #include <string_view> |
5 | 5 | #include <type_traits> |
6 | 6 |
|
7 | | -#if !defined __GNUC__ || __GNUC__ >= 12 |
8 | | -#define GCC_CONSTEXPR_WORKAROUND constexpr |
9 | | -#else |
10 | | -#define GCC_CONSTEXPR_WORKAROUND |
11 | | -#endif |
12 | | - |
13 | | -[[nodiscard]] inline GCC_CONSTEXPR_WORKAROUND bool operator==(const std::string& str, const char ch) noexcept |
| 7 | +[[nodiscard]] inline bool operator==(const std::string& str, const char ch) noexcept |
14 | 8 | { |
15 | 9 | return str.size() == 1 && str[0] == ch; |
16 | 10 | } |
17 | 11 |
|
18 | | -[[nodiscard]] inline GCC_CONSTEXPR_WORKAROUND bool operator==(const char ch, const std::string& str) noexcept |
| 12 | +[[nodiscard]] inline bool operator==(const char ch, const std::string& str) noexcept |
19 | 13 | { |
20 | 14 | return str == ch; |
21 | 15 | } |
22 | 16 |
|
23 | 17 | template<class CharT, class CharTraits, class Alloc> |
24 | | -GCC_CONSTEXPR_WORKAROUND std::basic_string<CharT, CharTraits, Alloc>& operator<<(std::basic_string<CharT, CharTraits, Alloc>& str, const char* s) |
| 18 | +inline std::basic_string<CharT, CharTraits, Alloc>& operator<<(std::basic_string<CharT, CharTraits, Alloc>& str, const char* s) |
25 | 19 | { |
26 | 20 | return str += s; |
27 | 21 | } |
28 | 22 |
|
29 | 23 | template<class CharT, class CharTraits, class Alloc> |
30 | | -GCC_CONSTEXPR_WORKAROUND std::basic_string<CharT, CharTraits, Alloc>& operator<<(std::basic_string<CharT, CharTraits, Alloc>& str, const std::basic_string<CharT, CharTraits, Alloc>& s) |
| 24 | +inline std::basic_string<CharT, CharTraits, Alloc>& operator<<(std::basic_string<CharT, CharTraits, Alloc>& str, const std::basic_string<CharT, CharTraits, Alloc>& s) |
31 | 25 | { |
32 | 26 | return str += s; |
33 | 27 | } |
34 | 28 |
|
35 | 29 | template <class CharT, class CharTraits, class Alloc, typename T, std::enable_if_t<std::is_integral_v<T> || std::is_floating_point_v<T>>* = nullptr> |
36 | | -GCC_CONSTEXPR_WORKAROUND std::basic_string<CharT, CharTraits, Alloc>& operator<<(std::basic_string<CharT, CharTraits, Alloc>& str, const T value) |
| 30 | +std::basic_string<CharT, CharTraits, Alloc>& operator<<(std::basic_string<CharT, CharTraits, Alloc>& str, const T value) |
37 | 31 | { |
38 | 32 | return str += std::to_string(value); |
39 | 33 | } |
40 | 34 |
|
41 | 35 | template <class CharT, class CharTraits, class Alloc, typename T, std::enable_if_t<std::is_integral_v<T> || std::is_floating_point_v<T>>* = nullptr> |
42 | | -GCC_CONSTEXPR_WORKAROUND std::basic_string<CharT, CharTraits, Alloc>& operator+=(std::basic_string<CharT, CharTraits, Alloc>& str, const T value) |
| 36 | +inline std::basic_string<CharT, CharTraits, Alloc>& operator+=(std::basic_string<CharT, CharTraits, Alloc>& str, const T value) |
43 | 37 | { |
44 | 38 | return str << value; |
45 | 39 | } |
46 | 40 |
|
47 | 41 | template <class CharT, class CharTraits, class Alloc, typename T, std::enable_if_t<std::is_integral_v<T> || std::is_floating_point_v<T>>* = nullptr> |
48 | | -GCC_CONSTEXPR_WORKAROUND std::basic_string<CharT, CharTraits, Alloc> operator+(std::basic_string<CharT, CharTraits, Alloc> str, const T value) |
| 42 | +inline std::basic_string<CharT, CharTraits, Alloc> operator+(std::basic_string<CharT, CharTraits, Alloc> str, const T value) |
49 | 43 | { |
50 | 44 | return str << value; |
51 | 45 | } |
52 | 46 |
|
53 | 47 | template<class CharT, class CharTraits, class Alloc> |
54 | | -GCC_CONSTEXPR_WORKAROUND std::basic_string<CharT, CharTraits, Alloc>& operator<<(std::basic_string<CharT, CharTraits, Alloc>& str, std::string_view sv) |
| 48 | +inline std::basic_string<CharT, CharTraits, Alloc>& operator<<(std::basic_string<CharT, CharTraits, Alloc>& str, std::string_view sv) |
55 | 49 | { |
56 | 50 | return str += sv; |
57 | 51 | } |
0 commit comments