aboutsummaryrefslogtreecommitdiffstats
path: root/docs/checks/README-temporary-iterator.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/checks/README-temporary-iterator.md')
-rw-r--r--docs/checks/README-temporary-iterator.md22
1 files changed, 22 insertions, 0 deletions
diff --git a/docs/checks/README-temporary-iterator.md b/docs/checks/README-temporary-iterator.md
new file mode 100644
index 00000000..c9dcd776
--- /dev/null
+++ b/docs/checks/README-temporary-iterator.md
@@ -0,0 +1,22 @@
+# temporary-iterator
+
+Detects when you're using using functions returning iterators (eg. `begin()` or `end()`) on a temporary container.
+
+#### Example
+
+ // temporary list returned by function
+ QList<type> getList()
+ {
+ QList<type> list;
+ ... add some items to list ...
+ return list;
+ }
+
+ // Will cause a crash if iterated using:
+
+ for (QList<type>::iterator it = getList().begin(); it != getList().end(); ++it)
+ {
+ ...
+ }
+
+because the end iterator was returned from a different container object than the begin iterator.