Add overloads of config::operator[] for std::string and const char*
This allows the indexing operator to be called with config::attribute_value that has an implicit conversion operator to std::string.
This commit is contained in:
parent
1362e03df8
commit
1eca3736f6
1 changed files with 40 additions and 2 deletions
|
@ -546,13 +546,51 @@ public:
|
|||
* Returns a reference to the attribute with the given @a key.
|
||||
* Creates it if it does not exist.
|
||||
*/
|
||||
attribute_value &operator[](config_key_type key);
|
||||
attribute_value& operator[](config_key_type key);
|
||||
|
||||
/**
|
||||
* Returns a reference to the attribute with the given @a key
|
||||
* or to a dummy empty attribute if it does not exist.
|
||||
*/
|
||||
const attribute_value &operator[](config_key_type key) const;
|
||||
const attribute_value& operator[](config_key_type key) const;
|
||||
|
||||
#ifdef USE_HETEROGENOUS_LOOKUPS
|
||||
/**
|
||||
* Returns a reference to the attribute with the given @a key.
|
||||
* Creates it if it does not exist.
|
||||
*/
|
||||
attribute_value& operator[](const std::string& key)
|
||||
{
|
||||
return operator[](config_key_type(key));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a reference to the attribute with the given @a key
|
||||
* or to a dummy empty attribute if it does not exist.
|
||||
*/
|
||||
const attribute_value& operator[](const std::string& key) const
|
||||
{
|
||||
return operator[](config_key_type(key));
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Returns a reference to the attribute with the given @a key.
|
||||
* Creates it if it does not exist.
|
||||
*/
|
||||
attribute_value& operator[](const char* key)
|
||||
{
|
||||
return operator[](config_key_type(key));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a reference to the attribute with the given @a key
|
||||
* or to a dummy empty attribute if it does not exist.
|
||||
*/
|
||||
const attribute_value& operator[](const char* key) const
|
||||
{
|
||||
return operator[](config_key_type(key));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a pointer to the attribute with the given @a key
|
||||
|
|
Loading…
Add table
Reference in a new issue