Skip to content

Commit e5eaf22

Browse files
authored
fix: make AttributeReference's SetType be a std::set (#23)
1 parent 3c4845a commit e5eaf22

File tree

1 file changed

+7
-18
lines changed

1 file changed

+7
-18
lines changed

libs/common/include/attribute_reference.hpp

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
#include <algorithm>
44
#include <cstddef>
55
#include <ostream>
6+
#include <set>
67
#include <string>
7-
#include <unordered_set>
88
#include <vector>
99

1010
#include <boost/container_hash/hash.hpp>
@@ -33,18 +33,7 @@ namespace launchdarkly {
3333
*/
3434
class AttributeReference {
3535
public:
36-
/**
37-
* Provides a hashing function for use with unordered sets.
38-
*/
39-
struct HashFunction {
40-
std::size_t operator()(AttributeReference const& ref) const {
41-
return boost::hash_range(ref.components_.begin(),
42-
ref.components_.end());
43-
}
44-
};
45-
46-
using SetType = std::unordered_set<AttributeReference,
47-
AttributeReference::HashFunction>;
36+
using SetType = std::set<AttributeReference>;
4837

4938
/**
5039
* Get the component of the attribute reference at the specified depth.
@@ -56,36 +45,36 @@ class AttributeReference {
5645
* @return The component at the specified depth or an empty string if the
5746
* depth is out of bounds.
5847
*/
59-
std::string const& component(std::size_t depth) const;
48+
[[nodiscard]] std::string const& component(std::size_t depth) const;
6049

6150
/**
6251
* Get the total depth of the reference.
6352
*
6453
* For example, depth() on the reference `/a/b/c` would return 3.
6554
* @return
6655
*/
67-
std::size_t depth() const;
56+
[[nodiscard]] std::size_t depth() const;
6857

6958
/**
7059
* Check if the reference is a "kind" reference. Either `/kind` or `kind`.
7160
*
7261
* @return True if it is a kind reference.
7362
*/
74-
bool is_kind() const;
63+
[[nodiscard]] bool is_kind() const;
7564

7665
/** Check if the reference is valid.
7766
*
7867
* @return True if the reference is valid.
7968
*/
80-
bool valid() const;
69+
[[nodiscard]] bool valid() const;
8170

8271
/**
8372
* The redaction name will always be an attribute reference compatible
8473
* string. So, for instance, a literal that contained `/attr` would be
8574
* converted to `/~1attr`.
8675
* @return String to use in redacted attributes.
8776
*/
88-
std::string const& redaction_name() const;
77+
[[nodiscard]] std::string const& redaction_name() const;
8978

9079
/**
9180
* Create an attribute from a string that is known to be an attribute

0 commit comments

Comments
 (0)