@@ -1292,36 +1292,24 @@ class sema
1292
1292
return false ;
1293
1293
}
1294
1294
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
1297
1296
if (
1298
1297
n.identifier
1299
1298
&& !n.is_function_with_this ()
1300
1299
&& (
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
+
1312
1309
// The following would be rejected anyway by the Cpp1 compiler,
1313
1310
// but including them here gives nicer and earlier error messages
1314
1311
|| 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 ()
1325
1313
)
1326
1314
)
1327
1315
{
0 commit comments