summaryrefslogtreecommitdiff
path: root/include/o3tl/safeint.hxx
diff options
context:
space:
mode:
Diffstat (limited to 'include/o3tl/safeint.hxx')
-rw-r--r--include/o3tl/safeint.hxx5
1 files changed, 5 insertions, 0 deletions
diff --git a/include/o3tl/safeint.hxx b/include/o3tl/safeint.hxx
index 6d8d1304fdf3..a5c212244c7c 100644
--- a/include/o3tl/safeint.hxx
+++ b/include/o3tl/safeint.hxx
@@ -234,6 +234,11 @@ make_unsigned(T value)
return value;
}
+// An implicit conversion from T2 to T1, useful in places where an explicit conversion from T2 to
+// T1 is needed (e.g., in list initialization, if the implicit conversion would be narrowing) but
+// tools like -fsanitize=implict-conversion should still be able to detect truncation:
+template<typename T1, typename T2> constexpr T1 narrowing(T2 value) { return value; }
+
}
#endif