Switch to unified view

a/src/smallut.h b/src/smallut.h
...
...
216
    class Internal;
216
    class Internal;
217
private:
217
private:
218
    Internal *m;
218
    Internal *m;
219
};
219
};
220
220
221
// Code for static initialization of an stl map. Somewhat like Boost.assign.
222
// Ref: http://stackoverflow.com/questions/138600/initializing-a-static-stdmapint-int-in-c
223
// Example use: map<int, int> m = create_map<int, int> (1,2) (3,4) (5,6) (7,8);
224
225
template <typename T, typename U>
226
class create_map {
227
private:
228
    std::map<T, U> m_map;
229
public:
230
    create_map(const T& key, const U& val) {
231
        m_map[key] = val;
232
    }
233
234
    create_map<T, U>& operator()(const T& key, const U& val) {
235
        m_map[key] = val;
236
        return *this;
237
    }
238
239
    operator std::map<T, U>() {
240
        return m_map;
241
    }
242
};
243
template <typename T>
244
class create_vector {
245
private:
246
    std::vector<T> m_vector;
247
public:
248
    create_vector(const T& val) {
249
        m_vector.push_back(val);
250
    }
251
252
    create_vector<T>& operator()(const T& val) {
253
        m_vector.push_back(val);
254
        return *this;
255
    }
256
257
    operator std::vector<T>() {
258
        return m_vector;
259
    }
260
};
261
262
#endif /* _SMALLUT_H_INCLUDED_ */
221
#endif /* _SMALLUT_H_INCLUDED_ */