Skip to content

Commit d967010

Browse files
fix: Enhance numeric casting with safe casting policy for improved safety
Signed-off-by: FrozenlemonTee <1115306170@qq.com>
1 parent a86d30e commit d967010

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/primitive/impl.cppm

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module;
22
#include <cstdint>
33
#include <tuple>
4+
#include <type_traits>
45

56
export module mcpplibs.primitives.primitive.impl;
67

@@ -61,8 +62,9 @@ private:
6162
underlying::traits<std::remove_cv_t<Target>>::rep_type;
6263

6364
auto const source_rep = underlying::traits<source_value_type>::to_rep(source);
64-
auto const target_rep = static_cast<target_rep_type>(
65-
static_cast<source_rep_type>(source_rep));
65+
auto const target_rep =
66+
policy::details::safe_numeric_cast<target_rep_type>(
67+
static_cast<source_rep_type>(source_rep));
6668
return underlying::traits<std::remove_cv_t<Target>>::from_rep(target_rep);
6769
}
6870

0 commit comments

Comments
 (0)