]> git.lyx.org Git - features.git/commitdiff
fix monolithic compilation and add usage comment
authorAndré Pönitz <poenitz@gmx.net>
Wed, 12 Mar 2008 19:39:14 +0000 (19:39 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Wed, 12 Mar 2008 19:39:14 +0000 (19:39 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23690 a592a061-630c-0410-9148-cb99ea01b6c8

src/support/foreach.h

index 3bcb1a03c83e54af6e79e19fa210209ca0259f5c..7689bdac7a13c16062261236c2135757baf746be 100644 (file)
@@ -8,10 +8,24 @@
  *
  * Full author contact details are available in file CREDITS.
  *
- * A collection of unicode conversion functions, using iconv.
  */
 
 #ifndef FOREACH_H
+#define FOREACH_H
+
+// Code stolen from Q_FOREACH, augmented to use a reference to the
+// original container instead of a copy. Copies are cheap (if not
+// mutated) for Qt's containers due to copy-on-write. The are less
+// cheap for Standard containers, that's why the modification.
+// Drawback is that we can't use temporary containers as they
+// will be destroyed before the loop is finished. So always write
+//  
+//  Container const & container = functionReturningTemporaryOrReference()
+//  foreach (ContainerItem const & item, container) {
+//   ...
+//  }
+//
+// to extend the lifetime of the reference.
 
 #if defined(Q_CC_GNU) && !defined(Q_CC_INTEL)