2727#include < fmt/xchar.h>
2828#endif // LOG4CXX_WCHAR_T_API || LOG4CXX_LOGCHAR_IS_WCHAR
2929#endif // LOG4CXX_ASYNC_BUFFER_SUPPORTS_FMT
30- #if defined(__cpp_concepts) && 202002 <= __cpp_concepts
30+
31+ #if defined(__cpp_concepts) && 202002 <= __cpp_concepts && defined(__GNUC__) && __GNUC__ <= 12
32+ // GCC 12 has broken concepts
33+ #define LOG4CXX_CONCEPTS 0
34+ #elif defined(__cpp_concepts) && 202002 <= __cpp_concepts
35+ #define LOG4CXX_CONCEPTS 1
36+ #else
37+ #define LOG4CXX_CONCEPTS 0
38+ #endif
39+
40+ #if LOG4CXX_CONCEPTS
3141#include < concepts>
3242#endif
3343
@@ -65,7 +75,7 @@ class LOG4CXX_EXPORT AsyncBuffer
6575 template <typename T>
6676 AsyncBuffer& operator <<(const T& value)
6777 {
68- #if defined(__cpp_concepts) && 202002 <= __cpp_concepts
78+ #if LOG4CXX_CONCEPTS
6979#if LOG4CXX_LOGCHAR_IS_UTF8
7080 if constexpr (requires (std::ostream& buf, T v) { buf << v; })
7181 {
@@ -103,12 +113,12 @@ class LOG4CXX_EXPORT AsyncBuffer
103113 else
104114 static_assert (false , " operator<<(std::wostream&) overload must be provided" );
105115#endif // !LOG4CXX_LOGCHAR_IS_UTF8
106- #else // !(defined(__cpp_concepts) && 202002 <= __cpp_concepts)
116+ #else // !LOG4CXX_CONCEPTS
107117 append ([value](LogCharMessageBuffer& msgBuf)
108118 {
109119 msgBuf << value;
110120 });
111- #endif // !(defined(__cpp_concepts) && 202002 <= __cpp_concepts)
121+ #endif // !LOG4CXX_CONCEPTS
112122 return *this ;
113123 }
114124
@@ -120,7 +130,7 @@ class LOG4CXX_EXPORT AsyncBuffer
120130 template <typename T>
121131 AsyncBuffer& operator <<(const T&& rvalue)
122132 {
123- #if defined(__cpp_concepts) && 202002 <= __cpp_concepts
133+ #if LOG4CXX_CONCEPTS
124134#if LOG4CXX_LOGCHAR_IS_UTF8
125135 if constexpr (requires (std::ostream& buf, T v) { buf << v; })
126136 {
@@ -158,12 +168,12 @@ class LOG4CXX_EXPORT AsyncBuffer
158168 else
159169 static_assert (false , " operator<<(std::wostream&) overload must be provided" );
160170#endif // !LOG4CXX_LOGCHAR_IS_UTF8
161- #else // !(defined(__cpp_concepts) && 202002 <= __cpp_concepts)
171+ #else // !LOG4CXX_CONCEPTS
162172 append ([value = std::move (rvalue)](LogCharMessageBuffer& msgBuf)
163173 {
164174 msgBuf << value;
165175 });
166- #endif // !(defined(__cpp_concepts) && 202002 <= __cpp_concepts)
176+ #endif // !LOG4CXX_CONCEPTS
167177 return *this ;
168178 }
169179
@@ -215,7 +225,7 @@ class LOG4CXX_EXPORT AsyncBuffer
215225 AsyncBuffer& operator =(const AsyncBuffer&) = delete ;
216226
217227 LOG4CXX_DECLARE_PRIVATE_MEMBER_PTR (Private, m_priv)
218- #if defined(__cpp_concepts) && 202002 <= __cpp_concepts
228+ #if LOG4CXX_CONCEPTS
219229 using MessageBufferAppender = std::function<void (CharMessageBuffer&)>;
220230
221231 /* *
@@ -231,14 +241,14 @@ class LOG4CXX_EXPORT AsyncBuffer
231241 */
232242 void append (const WideMessageBufferAppender& f);
233243#endif // LOG4CXX_WCHAR_T_API
234- #else // !(defined(__cpp_concepts) && 202002 <= __cpp_concepts)
244+ #else // !LOG4CXX_CONCEPTS
235245 using MessageBufferAppender = std::function<void (LogCharMessageBuffer&)>;
236246
237247 /* *
238248 * Append \c f to this buffer.
239249 */
240250 void append (const MessageBufferAppender& f);
241- #endif // !(defined(__cpp_concepts) && 202002 <= __cpp_concepts)
251+ #endif // !LOG4CXX_CONCEPTS
242252
243253#if LOG4CXX_ASYNC_BUFFER_SUPPORTS_FMT
244254 void initializeForFmt (StringViewType&& format_string, FmtArgStore&& args);
0 commit comments