Hi,
Rule 16.6.1 marks this example as non-compliant:
However it does not provide a compliant alternative. It's unclear if rule 16.6.1 wants us to:
a) Duplicate the function and create 2 versions for each order of the parameters, in order to guarantee symmetry (even if it may not be useful for the user, potentially being dead code):
b) Implement only 1 overload, but as a non-member function. This still does not solve the problem of "operator+ must be symmetrical", i.e that "1 + c" and "c + 1" must be supported.
Could you clarify?
Thanks!
Rule 16.6.1 marks this example as non-compliant:
Code:
C operator+( int32_t rhs ) const; // Non-compliant
However it does not provide a compliant alternative. It's unclear if rule 16.6.1 wants us to:
a) Duplicate the function and create 2 versions for each order of the parameters, in order to guarantee symmetry (even if it may not be useful for the user, potentially being dead code):
Code:
C operator+(C lhs, int32_t rhs );
C operator+(int32_t lhs, C rhs );
b) Implement only 1 overload, but as a non-member function. This still does not solve the problem of "operator+ must be symmetrical", i.e that "1 + c" and "c + 1" must be supported.
Code:
friend C operator+(C lhs, int32_t rhs );
Could you clarify?
Thanks!