|
constexpr | Key (K id) |
| Construct a new key.
|
|
| Key (Key const &)=default |
|
| Key (Key &&)=default |
|
Key & | operator= (Key const &)=default |
|
Key & | operator= (Key &&)=default |
|
template<typename U > |
| Key (Key< K, U > other) |
| Convert a key to a different key that could retrieve the same values.
|
|
constexpr K const & | getId () const noexcept |
| Return the identifier of this field.
|
|
template<typename U > |
constexpr bool | operator< (Key< K, U > const &other) const noexcept |
| Define sort order for Keys.
|
|
std::size_t | hash_value () const noexcept |
| Return a hash of this object.
|
|
|
constexpr bool | operator== (Key< K, V > const &other) const noexcept |
| Test for key equality.
|
|
template<typename U > |
constexpr std::enable_if_t<!std::is_same< U, V >::value, bool > | operator== (Key< K, U > const &) const noexcept |
| Test for key equality.
|
|
template<typename U > |
constexpr bool | operator!= (Key< K, U > const &other) const noexcept |
| Test for key equality.
|
|
template<typename K, typename V>
class lsst::afw::typehandling::Key< K, V >
Key for type-safe lookup in a GenericMap.
- Template Parameters
-
K | the logical type of the key (e.g., a string) |
V | the type of the value mapped to this key |
Key objects are equality-comparable, hashable, sortable, or printable if and only if K
is comparable, hashable, sortable, or printable, respectively. Key can be used in compile-time expressions if and only if K
can (in particular, Key<std::string, V>
cannot).
Definition at line 52 of file Key.h.
template<typename K , typename V >
template<typename U >
Define sort order for Keys.
This must be expressed as operator<
instead of std::less because only std::less<void> supports arguments of mixed types, and it cannot be specialized.
- Parameters
-
other | the key, possibly of a different type, to compare to |
- Returns
- equivalent to
this->getId() < other.getId()
- Warning
- this comparison operator provides a strict weak ordering so long as
K
does, but is not consistent with equality. In particular, keys with the same value of getId()
but different types will be equivalent but not equal.
Definition at line 143 of file Key.h.
template<typename V , typename K >
constexpr Key< K, V > makeKey |
( |
K const & | id | ) |
|
|
related |
Factory function for Key, to enable type parameter inference.
- Parameters
-
- Returns
- a key of the desired type
- Exception Safety
- Provides the same exception safety as the copy-constructor of
K
.
Calling this function prevents you from having to explicitly name the key type:
auto key = makeKey<int>("foo");
Definition at line 173 of file Key.h.