clang-tidy: getting postfix operator++ right

Viewed 110

I have a custom forward iterator type. It declares (among other stuff) this:

Iter& operator++();
Iter operator++(int);

clang-tidy complains about cert-dcl21-cpp (Clang-Tidy: Overloaded 'operator++' returns a non-constant object instead of a constant object type)

Now, naïve as I am, I changed the declaration to

Iter& operator++();
Iter const operator++(int);

Well, it now complains about readability-const-return-type (Return type 'const IndexAtomListPtr::Iter' is 'const'-qualified at the top level, which may reduce code readability without improving const correctness)

How can I satisfy clang-tidy?

The answer to the related question: overloaded "operator++" returns a non const, and clang-tidy complains is not sufficient, as it is exactly what I tried, but got the readability-const-return-type complain

0 Answers
Related