score
Home
Classes
Namespaces
Files
Loading...
Searching...
No Matches
StringFactoryKey.hpp
1
#pragma once
2
#include <score/tools/opaque/OpaqueString.hpp>
3
4
#include <score_lib_base_export.h>
5
// TODO rename file.
6
template
<
typename
Tag>
7
class
StringKey
:
OpaqueString
8
{
9
public
:
10
using
this_type
=
StringKey<Tag>
;
11
12
friend
struct
std::hash<
this_type
>;
13
friend
bool
operator==(
const
StringKey
& lhs,
const
StringKey
& rhs)
noexcept
14
{
15
return
static_cast<
const
OpaqueString
&
>
(lhs)
16
==
static_cast<
const
OpaqueString
&
>
(rhs);
17
}
18
friend
bool
operator!=(
const
StringKey
& lhs,
const
StringKey
& rhs)
noexcept
19
{
20
return
static_cast<
const
OpaqueString
&
>
(lhs)
21
!=
static_cast<
const
OpaqueString
&
>
(rhs);
22
}
23
friend
bool
operator<(
const
StringKey
& lhs,
const
StringKey
& rhs)
noexcept
24
{
25
return
static_cast<
const
OpaqueString
&
>
(lhs) <
static_cast<
const
OpaqueString
&
>
(rhs);
26
}
27
28
using
OpaqueString::OpaqueString;
29
30
auto
& toString() {
return
impl; }
31
auto
& toString()
const
{
return
impl; }
32
};
33
34
namespace
std
35
{
36
template
<
typename
T>
37
struct
hash<
StringKey
<T>>
38
{
39
std::size_t operator()(
const
StringKey<T>
& kagi)
const
noexcept
40
{
41
return
std::hash<std::string>()(kagi.toString());
42
}
43
};
44
}
OpaqueString
Definition
OpaqueString.hpp:7
StringKey
Definition
StringFactoryKey.hpp:8
std
STL namespace.