Sleipnir C++ API
Loading...
Searching...
No Matches
expression_type.hpp
1// Copyright (c) Sleipnir contributors
2
3#pragma once
4
5#include <stdint.h>
6
7#include <format>
8#include <utility>
9
10namespace slp {
11
15enum class ExpressionType : uint8_t {
17 NONE,
19 CONSTANT,
21 PARAMETER,
23 LINEAR,
25 QUADRATIC,
27 NONLINEAR
28};
29
30} // namespace slp
31
33template <>
34struct std::formatter<slp::ExpressionType> {
39 constexpr auto parse(std::format_parse_context& ctx) {
40 return m_underlying.parse(ctx);
41 }
42
49 template <typename FmtContext>
50 auto format(const slp::ExpressionType& type, FmtContext& ctx) const {
51 using enum slp::ExpressionType;
52
53 switch (type) {
54 case NONE:
55 return m_underlying.format("none", ctx);
56 case CONSTANT:
57 return m_underlying.format("constant", ctx);
58 case PARAMETER:
59 return m_underlying.format("parameter", ctx);
60 case LINEAR:
61 return m_underlying.format("linear", ctx);
62 case QUADRATIC:
63 return m_underlying.format("quadratic", ctx);
64 case NONLINEAR:
65 return m_underlying.format("nonlinear", ctx);
66 default:
67 std::unreachable();
68 }
69 }
70
71 private:
72 std::formatter<const char*> m_underlying;
73};
auto format(const slp::ExpressionType &type, FmtContext &ctx) const
Definition expression_type.hpp:50
constexpr auto parse(std::format_parse_context &ctx)
Definition expression_type.hpp:39