@@ -21,10 +21,36 @@ class Candidate extends TemplateFunction {
2121 }
2222}
2323
24- from Candidate c , Function f
24+ from
25+ Candidate c , Function f , Function overload , Function overloaded , string msg ,
26+ string firstMsgSegment
2527where
2628 not isExcluded ( f ,
2729 OperatorsPackage:: functionThatContainsForwardingReferenceAsItsArgumentOverloadedQuery ( ) ) and
2830 not f .isDeleted ( ) and
29- f = c .getAnOverload ( )
30- select f , "Function overloads a $@ with a forwarding reference parameter." , c , "function"
31+ f = c .getAnOverload ( ) and
32+ // allow for overloading with different number of parameters, because there is no
33+ // confusion on what function will be called.
34+ f .getNumberOfParameters ( ) = c .getNumberOfParameters ( ) and
35+ //build a dynamic select statement that guarantees to read that the overloading function is the explicit one
36+ if
37+ ( f instanceof CopyConstructor or f instanceof MoveConstructor ) and
38+ f .isCompilerGenerated ( )
39+ then (
40+ (
41+ f instanceof CopyConstructor and
42+ msg = "implicit copy constructor"
43+ or
44+ f instanceof MoveConstructor and
45+ msg = "implicit move constructor"
46+ ) and
47+ firstMsgSegment = " with a forwarding reference parameter " and
48+ overloaded = f and
49+ overload = c
50+ ) else (
51+ msg = "function with a forwarding reference parameter" and
52+ firstMsgSegment = " " and
53+ overloaded = c and
54+ overload = f
55+ )
56+ select overload , "Function" + firstMsgSegment + "overloads a $@." , overloaded , msg
0 commit comments