Vanetza
Loading...
Searching...
No Matches
m49_code.hpp
1#pragma once
2#include <cstdint>
3#include <functional>
4
5namespace vanetza
6{
7namespace geodesy
8{
9
10/**
11 * Standard country or area codes for statistical use by M49 standard.
12 * \see https://unstats.un.org/unsd/methodology/m49/
13 */
15{
16public:
17 explicit constexpr M49Code(uint16_t value) : m_value(value) {}
18 constexpr uint16_t value() const { return m_value; }
19
20 bool operator==(M49Code other) const { return m_value == other.m_value; }
21 bool operator!=(M49Code other) const { return m_value != other.m_value; }
22
23private:
24 uint16_t m_value;
25};
26
27} // namespace geodesy
28} // namespace vanetza
29
30namespace std
31{
32template<>
33struct hash<vanetza::geodesy::M49Code>
34{
35 std::size_t operator()(vanetza::geodesy::M49Code code) const
36 {
37 return std::hash<uint16_t>{}(code.value());
38 }
39};
40
41template<>
42struct less<vanetza::geodesy::M49Code>
43{
44 bool operator()(vanetza::geodesy::M49Code a, vanetza::geodesy::M49Code b) const
45 {
46 return a.value() < b.value();
47 }
48};
49} // namespace std