exchange
Low-latency exchange in C++
Loading...
Searching...
No Matches
price.hpp
Go to the documentation of this file.
1#pragma once
2#include <functional>
3#include <cstdint>
4#include <compare>
5#include <limits>
6
7namespace exchange::server
8{
9struct Price
10{
11 uint64_t value{};
12 constexpr Price() = default;
13 constexpr explicit Price(const uint64_t value) : value(value)
14 {
15 }
16
17 constexpr auto operator<=>(const Price &) const = default;
18};
19} // namespace exchange::server
20
21template <> struct std::hash<exchange::server::Price>
22{
23 std::size_t operator()(const exchange::server::Price &price) const noexcept
24 {
25 return std::hash<uint64_t>{}(price.value);
26 }
27};
28
29template <> class std::numeric_limits<exchange::server::Price> : public std::numeric_limits<uint64_t>
30{
31 public:
32 static constexpr bool is_specialized = true;
33
34 static constexpr exchange::server::Price max() noexcept
35 {
36 return exchange::server::Price{std::numeric_limits<uint64_t>::max()};
37 }
38
39 static constexpr exchange::server::Price min() noexcept
40 {
41 return exchange::server::Price{std::numeric_limits<uint64_t>::min()};
42 }
43};
static constexpr exchange::server::Price max() noexcept
Definition price.hpp:34
static constexpr exchange::server::Price min() noexcept
Definition price.hpp:39
static constexpr bool is_specialized
Definition price.hpp:32
Definition main.hpp:4
Definition cli_parsing.hpp:10
Definition price.hpp:10
uint64_t value
Definition price.hpp:11
constexpr auto operator<=>(const Price &) const =default
constexpr Price(const uint64_t value)
Definition price.hpp:13
constexpr Price()=default
std::size_t operator()(const exchange::server::Price &price) const noexcept
Definition price.hpp:23