use std c++11 initializer instead of create_xx hacks
This commit is contained in:
@@ -218,45 +218,4 @@ private:
|
||||
Internal *m;
|
||||
};
|
||||
|
||||
// Code for static initialization of an stl map. Somewhat like Boost.assign.
|
||||
// Ref: http://stackoverflow.com/questions/138600/initializing-a-static-stdmapint-int-in-c
|
||||
// Example use: map<int, int> m = create_map<int, int> (1,2) (3,4) (5,6) (7,8);
|
||||
|
||||
template <typename T, typename U>
|
||||
class create_map {
|
||||
private:
|
||||
std::map<T, U> m_map;
|
||||
public:
|
||||
create_map(const T& key, const U& val) {
|
||||
m_map[key] = val;
|
||||
}
|
||||
|
||||
create_map<T, U>& operator()(const T& key, const U& val) {
|
||||
m_map[key] = val;
|
||||
return *this;
|
||||
}
|
||||
|
||||
operator std::map<T, U>() {
|
||||
return m_map;
|
||||
}
|
||||
};
|
||||
template <typename T>
|
||||
class create_vector {
|
||||
private:
|
||||
std::vector<T> m_vector;
|
||||
public:
|
||||
create_vector(const T& val) {
|
||||
m_vector.push_back(val);
|
||||
}
|
||||
|
||||
create_vector<T>& operator()(const T& val) {
|
||||
m_vector.push_back(val);
|
||||
return *this;
|
||||
}
|
||||
|
||||
operator std::vector<T>() {
|
||||
return m_vector;
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* _SMALLUT_H_INCLUDED_ */
|
||||
|
||||
Reference in New Issue
Block a user