Porytiles
Loading...
Searching...
No Matches
palette_index.hpp
Go to the documentation of this file.
1#pragma once
2
3// ReSharper disable once CppUnusedIncludeDirective
4#include <compare>
5#include <cstddef>
6#include <string>
7
9
10namespace porytiles {
11
12inline constexpr std::size_t colors_per_palette = 16;
13
22 public:
23 // NOLINTNEXTLINE(google-explicit-constructor)
24 PaletteIndex(std::size_t value) : value_{value}
25 {
27 panic("invalid PaletteIndex value " + std::to_string(value));
28 }
29 }
30
31 auto operator<=>(const PaletteIndex &) const = default;
32
33 // NOLINTNEXTLINE
34 operator const std::size_t &() const &
35 {
36 return value_;
37 }
38
39 // NOLINTNEXTLINE
40 operator std::size_t &&() &&
41 {
42 return std::move(value_);
43 }
44
45 [[nodiscard]] const std::size_t &value() const &
46 {
47 return value_;
48 }
49
50 [[nodiscard]] std::size_t &&value() &&
51 {
52 return std::move(value_);
53 }
54
55 [[nodiscard]] std::size_t index() const
56 {
57 return value_;
58 }
59
60 private:
61 std::size_t value_{};
62};
63
64} // namespace porytiles
Represents a palette index value within a particular palette.
std::size_t && value() &&
const std::size_t & value() const &
std::size_t index() const
auto operator<=>(const PaletteIndex &) const =default
PaletteIndex(std::size_t value)
constexpr std::size_t colors_per_palette
void panic(const StringViewSourceLoc &s)
Unconditionally terminates the program with a panic message.
Definition panic.cpp:43