@@ -1292,36 +1292,24 @@ class sema
12921292 return false ;
12931293 }
12941294
1295- // Require that comparison operators, bitwise binary operators,
1296- // assignment operators, and comparison operators must be members
1295+ // Require that ~/comparison/assignment operators must be members
12971296 if (
12981297 n.identifier
12991298 && !n.is_function_with_this ()
13001299 && (
1301- n.has_name (" operator==" )
1302- || n.has_name (" operator!=" )
1303- || n.has_name (" operator<" )
1304- || n.has_name (" operator<=" )
1305- || n.has_name (" operator>" )
1306- || n.has_name (" operator>=" )
1307- || n.has_name (" operator<=>" )
1308- || n.has_name (" operator&" )
1309- || n.has_name (" operator|" )
1310- || n.has_name (" operator^" )
1311- || n.is_comparison ()
1300+ // Note re comparisons: The reason I'm restricting comparisons to be members
1301+ // is because with comparison symmetry (since C++20, derived from Cpp2)
1302+ // there's no longer a need for a type author to write them as nonmembers,
1303+ // and I want to discourage that habit by banning nonmembers. However, there
1304+ // could be a motivation to write them as nonmembers in the case where the
1305+ // type author doesn't provide them -- if that turns out to be important we
1306+ // can remove the restriction on nonmember comparisons here
1307+ n.is_comparison ()
1308+
13121309 // The following would be rejected anyway by the Cpp1 compiler,
13131310 // but including them here gives nicer and earlier error messages
13141311 || n.has_name (" operator~" )
1315- || n.has_name (" operator+=" )
1316- || n.has_name (" operator-=" )
1317- || n.has_name (" operator*=" )
1318- || n.has_name (" operator/=" )
1319- || n.has_name (" operator%=" )
1320- || n.has_name (" operator&=" )
1321- || n.has_name (" operator|=" )
1322- || n.has_name (" operator^=" )
1323- || n.has_name (" operator<<=" )
1324- || n.has_name (" operator>>=" )
1312+ || n.is_compound_assignment ()
13251313 )
13261314 )
13271315 {
0 commit comments