5 #ifndef FORBCC_UNIQUES_LIST_H 6 #define FORBCC_UNIQUES_LIST_H 11 #include <type_traits> 21 using set_t = std::map<std::string, int>;
27 using const_T =
typename std::add_const<T>::type;
44 virtual bool insert(std::string key,
const T &value) {
45 auto mypair = make_pair(key, _list.size());
47 if (_set.insert(mypair).second) {
49 _list.push_back(value);
63 return _set.find(key) != _set.end();
69 return _list[_set.at(key)];
75 return _list[_set.at(key)];
81 #endif //FORBCC_UNIQUES_LIST_H typename std::add_const< parameter >::type const_T
Alias of the const version of the template type T.
Definition: ordered_unique_list.hpp:27
const list_t & list() const
Returns a const reference to the list of the elements.
Definition: ordered_unique_list.hpp:57
virtual bool insert(std::string key, const T &value)
Inserts a new value within the list if the corrisponding key is not present.
Definition: ordered_unique_list.hpp:44
A template that can be used to declare a list of unique ordered items.
Definition: ordered_unique_list.hpp:16
bool contains(std::string key) const
Returns true if the given key is present within the set of keys.
Definition: ordered_unique_list.hpp:62
T & operator[](std::string key)
Returns a reference to an element from its key.
Definition: ordered_unique_list.hpp:68
Definition: code_ostream.hpp:11
std::map< std::string, int > set_t
The type of the set of keys, used to access the list.
Definition: ordered_unique_list.hpp:21
std::vector< parameter > list_t
The type of the list.
Definition: ordered_unique_list.hpp:24
const_T & operator[](std::string key) const
Same as operator[](std::string), but returns a const_T instead, when used on a const reference to the...
Definition: ordered_unique_list.hpp:74