https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111504
Bug ID: 111504 Summary: compare operator not defined for recursive data types on C++20 Product: gcc Version: 13.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: xgao at nvidia dot com Target Milestone: --- Related bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111316 The following code works on C++17 but not C++20: #include <cstdint> #include <type_traits> #include <vector> template <typename T1, typename T2> static auto hasLessThanHelper(int) -> decltype(std::declval<T1>() < std::declval<T2>(), std::true_type{}); template <typename, typename> static auto hasLessThanHelper(long) -> std::false_type; template <typename T1, typename T2> struct hasLessThan : decltype(hasLessThanHelper<T1, T2>(0)) {}; struct DynamicType { using T1 = int64_t; using T2 = std::vector<DynamicType>; }; template < typename DT, typename = std::enable_if_t< (hasLessThan<typename DT::T1, typename DT::T1>::value || hasLessThan<typename DT::T1, typename DT::T2>::value || hasLessThan<typename DT::T2, typename DT::T1>::value || hasLessThan<typename DT::T2, typename DT::T2>::value)>> inline constexpr bool operator<(const DT& x, const DT& y) { // implementation omitted return true; } int main() { using DT = DynamicType; // This assert works on C++17, but fails on C++20 static_assert(hasLessThan<std::vector<DT>, std::vector<DT>>::value); }