aboutsummaryrefslogtreecommitdiffstats
path: root/src/checks/level1/README-detaching-temporary.md
blob: 60d0196c29dec19a147e6f20ba8c99d7d1b16ce5 (plain)
1
2
3
4
5
6
7
# detaching-temporary

Finds places where you're calling non-const member functions on temporaries.
For example `getList().first()`, which would detach if the container is shared.

There can be some false-positives, for example `someHash.values().first()` because refcount is 1.
But `constFirst()` is a good default, so you should try to use it wherever you can, since it's not practical to inspect all code and figure out if the container is shared or not.