mirror of
https://github.com/NixOS/nix
synced 2025-06-24 22:11:15 +02:00
Use transparent comparators for StringMap
and StringPairs
This commit is contained in:
parent
8ee513379a
commit
49d026083b
1 changed files with 19 additions and 2 deletions
|
@ -12,8 +12,25 @@
|
|||
namespace nix {
|
||||
|
||||
typedef std::list<std::string> Strings;
|
||||
typedef std::map<std::string, std::string> StringMap;
|
||||
typedef std::map<std::string, std::string> StringPairs;
|
||||
|
||||
/**
|
||||
* Alias to ordered std::string -> std::string map container with transparent comparator.
|
||||
*
|
||||
* Used instead of std::map<std::string, std::string> to use C++14 N3657 [1]
|
||||
* heterogenous lookup consistently across the whole codebase.
|
||||
* Transparent comparators get rid of creation of unnecessary
|
||||
* temporary variables when looking up keys by `std::string_view`
|
||||
* or C-style `const char *` strings.
|
||||
*
|
||||
* [1]: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3657.htm
|
||||
*/
|
||||
using StringMap = std::map<std::string, std::string, std::less<>>;
|
||||
/**
|
||||
* Alias to an ordered map of std::string -> std::string. Uses transparent comparator.
|
||||
*
|
||||
* @see StringMap
|
||||
*/
|
||||
using StringPairs = StringMap;
|
||||
|
||||
/**
|
||||
* Alias to ordered set container with transparent comparator.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue