|
a/src/utils/smallut.h |
|
b/src/utils/smallut.h |
|
... |
|
... |
184 |
|
184 |
|
185 |
#ifndef deleteZ
|
185 |
#ifndef deleteZ
|
186 |
#define deleteZ(X) {delete X;X = 0;}
|
186 |
#define deleteZ(X) {delete X;X = 0;}
|
187 |
#endif
|
187 |
#endif
|
188 |
|
188 |
|
|
|
189 |
// Code for static initialization of an stl map. Somewhat like Boost.assign.
|
|
|
190 |
// Ref: http://stackoverflow.com/questions/138600/initializing-a-static-stdmapint-int-in-c
|
|
|
191 |
// Example use: map<int, int> m = map_list_of (1,2) (3,4) (5,6) (7,8);
|
|
|
192 |
|
|
|
193 |
template <typename T, typename U>
|
|
|
194 |
class create_map
|
|
|
195 |
{
|
|
|
196 |
private:
|
|
|
197 |
std::map<T, U> m_map;
|
|
|
198 |
public:
|
|
|
199 |
create_map(const T& key, const U& val)
|
|
|
200 |
{
|
|
|
201 |
m_map[key] = val;
|
|
|
202 |
}
|
|
|
203 |
|
|
|
204 |
create_map<T, U>& operator()(const T& key, const U& val)
|
|
|
205 |
{
|
|
|
206 |
m_map[key] = val;
|
|
|
207 |
return *this;
|
|
|
208 |
}
|
|
|
209 |
|
|
|
210 |
operator std::map<T, U>()
|
|
|
211 |
{
|
|
|
212 |
return m_map;
|
|
|
213 |
}
|
|
|
214 |
};
|
|
|
215 |
|
189 |
#endif /* _SMALLUT_H_INCLUDED_ */
|
216 |
#endif /* _SMALLUT_H_INCLUDED_ */
|