Swarm-NG  1.1
macros.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005 by Mario Juric *
3  * mjuric@astro.Princeton.EDU *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
20 
26 #ifndef _astro_macros_h
27 #define _astro_macros_h
28 
29 #define FOREACH2j(C, i_, x) for(C i_ = (x).begin(); i_ != (x).end(); ++i_)
30 #define FOREACH2(C, x) FOREACH2j(C, i, x)
31 
32 #define REVEACH2j(C, i_, x) for(C i_ = (x).rbegin(); i_ != (x).rend(); ++i_)
33 #define REVEACH2(C, x) REVEACH2j(C, i, x)
34 
35 #define FOREACHj(i_, x) for(typeof((x).begin()) i_ = (x).begin(); i_ != (x).end(); ++i_)
36 #define FOREACH(x) FOREACHj(i, x)
37 
38 #define REVEACHj(i_, x) for(typeof((x).rbegin()) i_ = (x).rbegin(); i_ != (x).rend(); ++i_)
39 #define REVEACH(x) REVEACHj(i, x)
40 
41 #define FORj(i, i0, i1) for(int i = i0; i != i1; ++i)
42 #define FOR(i0, i1) FORj(i, i0, i1)
43 
44 #define REVj(i, i0, i1) for(int i = i0; i != i1; --i)
45 #define REV(i0, i1) REVj(i, i0, i1)
46 
47 #define OSTREAM(T) std::ostream &operator <<(std::ostream &out, T)
48 #define ISTREAM(T) std::istream &operator >>(std::istream &in, T)
49 
50 #endif // _astro_macros_h