Use gcc-c++ >= 4.5
[platform/upstream/libzypp.git] / zypp / base / Easy.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file       zypp/base/Easy.h
10  *
11 */
12 #ifndef ZYPP_BASE_EASY_H
13 #define ZYPP_BASE_EASY_H
14
15 /** Convenient for-loops using iterator.
16  * \code
17  *  std::set<std::string> _store;
18  *  for_( it, _store.begin(), _store.end() )
19  *  {
20  *    cout << *it << endl;
21  *  }
22  * \endcode
23 */
24 #define for_(IT,BEG,END) for ( auto IT = BEG, _for_end = END; IT != _for_end; ++IT )
25 #define for_each_(IT,CONT) for_( IT, CONT.begin(), CONT.end() )
26
27 /** Simple C-array iterator
28  * \code
29  *  const char * defstrings[] = { "",  "a", "default", "two words" };
30  *  for_( it, arrayBegin(defstrings), arrayEnd(defstrings) )
31  *    cout << *it << endl;
32  * \endcode
33 */
34 #define arrayBegin(A) (&A[0])
35 #define arraySize(A)  (sizeof(A)/sizeof(*A))
36 #define arrayEnd(A)   (&A[0] + arraySize(A))
37
38 ///////////////////////////////////////////////////////////////////
39 namespace zypp
40 { /////////////////////////////////////////////////////////////////
41   /////////////////////////////////////////////////////////////////
42 } // namespace zypp
43 ///////////////////////////////////////////////////////////////////
44 #endif // ZYPP_BASE_EASY_H