aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/skiff/skiff-inl.h
blob: a3f68a93745cbe0a8ebbcc3d7c2ab4277e20b312 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#pragma once

#ifndef SKIFF_H
#error "Direct inclusion of this file is not allowed, include skiff.h"
// For the sake of sane code completion.
#include "skiff.h"
#endif
#undef SKIFF_H

namespace NSkiff {

////////////////////////////////////////////////////////////////////////////////

template <EWireType wireType>
constexpr auto TUnderlyingIntegerType<wireType>::F() {
    if constexpr (wireType == EWireType::Int8) {
        return i8{};
    } else if constexpr (wireType == EWireType::Int16) {
        return i16{};
    } else if constexpr (wireType == EWireType::Int32) {
        return i32{};
    } else if constexpr (wireType == EWireType::Int64) {
        return i64{};
    } else if constexpr (wireType == EWireType::Uint8) {
        return ui8{};
    } else if constexpr (wireType == EWireType::Uint16) {
        return ui16{};
    } else if constexpr (wireType == EWireType::Uint32) {
        return ui32{};
    } else if constexpr (wireType == EWireType::Uint64) {
        return ui64{};
    } else {
        static_assert(wireType == EWireType::Int8, "expected integer wire type");
    }
}

////////////////////////////////////////////////////////////////////////////////

} // namespace NSkiff