ref: refs/heads/master
commit b49942ca25ba20dd173d137109336d26b8822ee3
Author: Michael Andres
Date: Fri Apr 10 15:32:17 2009 +0200
Add convenience macros arrayBegin/arrayEnd for C-array iteration.
---
zypp/base/Easy.h | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/zypp/base/Easy.h b/zypp/base/Easy.h
index 24fd556..6085734 100644
--- a/zypp/base/Easy.h
+++ b/zypp/base/Easy.h
@@ -23,6 +23,17 @@
*/
#define for_(IT,BEG,END) for ( typeof(BEG) IT = BEG, _for_end = END; IT != _for_end; ++IT )
+/** Simple C-array iterator
+ * \code
+ * const char * defstrings[] = { "", "a", "default", "two words" };
+ * for_( it, arrayBegin(defstrings), arrayEnd(defstrings) )
+ * cout << *it << endl;
+ * \endcode
+*/
+#define arrayBegin(A) (&A[0])
+#define arrayEnd(A) (&A[0] + (sizeof(A)/sizeof(*A)))
+
+
///////////////////////////////////////////////////////////////////
namespace zypp
{ /////////////////////////////////////////////////////////////////
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org