3#include <xrpl/beast/utility/instrumentation.h>
13template <
class Src,
class Dest>
17 : sizeof(Dest) >= sizeof(Src));
19template <
class Dest,
class Src>
27 sizeof(Dest) >=
sizeof(Src) + not_same,
28 "Destination is too small to hold all values of source");
29 return static_cast<Dest
>(s);
32template <
class Dest,
class Src>
36 return static_cast<Dest
>(safe_cast<std::underlying_type_t<Dest>>(s));
39template <
class Dest,
class Src>
50template <
class Dest,
class Src>
56 "Only unsafe if casting signed to unsigned or "
57 "destination is too small");
58 return static_cast<Dest
>(s);
61template <
class Dest,
class Src>
65 return static_cast<Dest
>(unsafe_cast<std::underlying_type_t<Dest>>(s));
68template <
class Dest,
class Src>
75template <
class Dest,
class Src>
81 return static_cast<Dest
>(s);
83 auto* result =
dynamic_cast<Dest
>(s);
84 XRPL_ASSERT(result !=
nullptr,
"xrpl::safe_downcast : pointer downcast is valid");
89template <
class Dest,
class Src>
97 "xrpl::safe_downcast : reference downcast is valid");
99 return static_cast<Dest
>(s);
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Dest safe_downcast(Src *s) noexcept
constexpr std::enable_if_t< std::is_integral_v< Dest > &&std::is_integral_v< Src >, Dest > unsafe_cast(Src s) noexcept
constexpr std::enable_if_t< std::is_integral_v< Dest > &&std::is_integral_v< Src >, Dest > safe_cast(Src s) noexcept