aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/yt/misc/cast.h
blob: ccf1eb21a6b7263bc09259758ae6b68466a7829f (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
40
41
#pragma once

#include "enum.h"

#include <library/cpp/yt/exception/exception.h>

#include <optional>

namespace NYT {

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

template <class T, class S>
constexpr bool CanFitSubtype();

template <class T, class S>
constexpr bool IsInIntegralRange(S value);

template <class T, class S>
constexpr std::optional<T> TryCheckedIntegralCast(S value);

template <class T, class S>
T CheckedIntegralCast(S value);

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

template <class T, class S>
    requires TEnumTraits<T>::IsEnum
constexpr std::optional<T> TryCheckedEnumCast(S value, bool enableUnknown = false);

template <class T, class S>
    requires TEnumTraits<T>::IsEnum
T CheckedEnumCast(S value);

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

} // namespace NYT

#define CAST_INL_H_
#include "cast-inl.h"
#undef CAST_INL_H_