Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PIM
KItinerary
Commits
e8082c8c
Commit
e8082c8c
authored
Aug 27, 2021
by
Volker Krause
Browse files
Add std::hash for AlphaId (and thus IataCode)
parent
c358b2e5
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/lib/knowledgedb/alphaid.h
View file @
e8082c8c
...
...
@@ -12,6 +12,7 @@
#include <QString>
#include <cstdint>
#include <functional>
namespace
KItinerary
{
namespace
KnowledgeDb
{
...
...
@@ -76,6 +77,11 @@ public:
return
Internal
::
alphaIdToString
(
m_id
,
N
);
}
/** @internal for std::hash */
inline
constexpr
T
value
()
const
{
return
m_id
;
}
private:
T
m_id
=
{};
};
...
...
@@ -91,3 +97,14 @@ inline QDebug operator<<(QDebug dbg, KItinerary::KnowledgeDb::AlphaId<T, N> id)
return
dbg
;
}
namespace
std
{
template
<
typename
T
,
int
N
>
struct
hash
<
KItinerary
::
KnowledgeDb
::
AlphaId
<
T
,
N
>>
{
typedef
KItinerary
::
KnowledgeDb
::
AlphaId
<
T
,
N
>
argument_type
;
typedef
std
::
size_t
result_type
;
result_type
operator
()(
argument_type
id
)
const
noexcept
{
return
std
::
hash
<
T
>
()(
id
.
value
());
}
};
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment