We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 57a9b32 commit a09637fCopy full SHA for a09637f
include/safe.hpp
@@ -10,3 +10,4 @@
10
#include <safe/object.hpp>
11
#include <safe/value.hpp>
12
#include <safe/var.hpp>
13
+#include <safe/safe_cast.hpp>
include/safe/safe_cast.hpp
@@ -0,0 +1,21 @@
1
+#pragma once
2
+
3
4
+#include <safe/detail/concepts.hpp>
5
+#include <safe/detail/fwd.hpp>
6
+#include <safe/var.hpp>
7
8
+#include <concepts>
9
+template<
+ typename T,
+ safe::Var F>
14
+requires (
15
+ std::is_convertible_v<typename F::value_type, T> and
16
+ safe::detail::integral_type<T>::requirement >= F::requirement)
17
+[[nodiscard]] SAFE_INLINE constexpr auto safe_cast(
18
+ F const & src
19
+) {
20
+ return static_cast<T>(src.unsafe_value_);
21
+}
0 commit comments