MIRA
base
include
utils
Foreach.h
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2012 by
3
* MetraLabs GmbH (MLAB), GERMANY
4
* and
5
* Neuroinformatics and Cognitive Robotics Labs (NICR) at TU Ilmenau, GERMANY
6
* All rights reserved.
7
*
8
* Contact: info@mira-project.org
9
*
10
* Commercial Usage:
11
* Licensees holding valid commercial licenses may use this file in
12
* accordance with the commercial license agreement provided with the
13
* software or, alternatively, in accordance with the terms contained in
14
* a written agreement between you and MLAB or NICR.
15
*
16
* GNU General Public License Usage:
17
* Alternatively, this file may be used under the terms of the GNU
18
* General Public License version 3.0 as published by the Free Software
19
* Foundation and appearing in the file LICENSE.GPL3 included in the
20
* packaging of this file. Please review the following information to
21
* ensure the GNU General Public License version 3.0 requirements will be
22
* met: http://www.gnu.org/copyleft/gpl.html.
23
* Alternatively you may (at your option) use any later version of the GNU
24
* General Public License if such license has been publicly approved by
25
* MLAB and NICR (or its successors, if any).
26
*
27
* IN NO EVENT SHALL "MLAB" OR "NICR" BE LIABLE TO ANY PARTY FOR DIRECT,
28
* INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
29
* THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF "MLAB" OR
30
* "NICR" HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
*
32
* "MLAB" AND "NICR" SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING,
33
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
34
* FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
35
* ON AN "AS IS" BASIS, AND "MLAB" AND "NICR" HAVE NO OBLIGATION TO
36
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR MODIFICATIONS.
37
*/
38
47
#ifndef _MIRA_FOREACH_H_
48
#define _MIRA_FOREACH_H_
49
51
52
// Since Boost >= 1.48 the very common "define foreach BOOST_FOREACH" causes
53
// a lot of problems: https://svn.boost.org/trac/boost/ticket/6131
54
// Therefore, we first use a "undef foreach" to ensure, that we have a 'clean'
55
// environment to apply a work-around (see below).
56
// Especially, this is necessary when include files of other libraries, which
57
// also for the "define foreach BOOST_FOREACH" (like Qt) were included before
58
// this file.
59
#undef foreach
60
#undef foreach_reverse
61
63
64
#ifndef Q_MOC_RUN
65
#include <boost/foreach.hpp>
66
#include <boost/version.hpp>
67
#include <boost/typeof/typeof.hpp>
68
#endif
69
71
72
// Boost versions >= 1.48 need a work-around for foreach (see below). But on
73
// some systems, the suggested work-around is already included in the boost
74
// version provided by the system vendor. Therefore, we need to detect this
75
// situation to skip the suggested work-around.
76
// Unfortunately, the only way to detect this situation seems to check the
77
// gcc and boost versions. At the moment, this combination seems to be unique
78
// enough.
79
80
#ifdef __GNUC__
81
# if (defined __GNUC_RH_RELEASE__) && (BOOST_VERSION == 105300)
82
// RedHat Enterprise / CentOS 7 with Boost 1.53.0
83
# define MIRA_SKIP_BOOST_FOREACH_WORKAROUND_6131
84
# endif
85
#endif
86
88
89
// Suggested work-around for problems with "define foreach BOOST_FOREACH" with
90
// Boost version >= 1.48. For more details, please here the following ticket:
91
// https://svn.boost.org/trac/boost/ticket/6131
92
// The work-around is based on the following comment on this issue:
93
// https://svn.boost.org/trac/boost/ticket/6131#comment:21
94
namespace
boost
{
95
#if (BOOST_VERSION != 104900) && !defined(MIRA_SKIP_BOOST_FOREACH_WORKAROUND_6131)
96
namespace
BOOST_FOREACH =
foreach
;
97
#endif
98
}
99
101
102
// Note: we do not need to enter a namespace here, since all macros are in
103
// the global namespace anyway
104
148
#undef foreach // QT might have defined it already (but boost foreach is much better and compatible!!)
149
// workaround for eclipse with CDT 8.0 (that is able to parse the new C++11
150
// range-based 'for' expression, but not the BOOST_FOREACH macro)
151
#ifdef __CDT_PARSER__
152
# define foreach(i,c) for(i:c)
153
#else
154
# define foreach BOOST_FOREACH
155
#endif
156
157
167
#undef foreach_reverse
168
#define foreach_reverse BOOST_REVERSE_FOREACH
169
191
#define foreachIt(var, container) for(auto var=container.begin();var!=container.end();++var)
192
194
195
#endif
boost
Definition:
SyncTimedRead.h:62
SVN-r10330 , Generated on Sat Sep 7 2024 02:32:40 for MIRA by
1.8.14