I made a macro for the "implies" operator. It works fine in general, but breaks on Clang when used in a concept or a requires-clause.
namespace detail{ template <typename T> concept BoolLike = requires(T &&t) {(T &&)t ? true : false;}; struct Implies { template <BoolLike T> friend constexpr bool operator||(T &&lhs, Implies) { return !bool((T &&)lhs); } };}#define IMPLIES ||::detail::Implies{}||template <typename T>concept A = true IMPLIES true;static_assert(A<int>);
Clang says:
<source>:19:18: error: atomic constraint must be of type 'bool' (found '::detail::Implies') 19 | concept A = true IMPLIES true; | ^~~~~~~<source>:16:19: note: expanded from macro 'IMPLIES' 16 | #define IMPLIES ||::detail::Implies{}|| | ^~~~~~~~~~~~~~~~~~~
While GCC and MSVC happily accept this code. Which compiler is correct?