Skip to content

Commit

Permalink
Add `constexpr' to functions that can throw an exception
Browse files Browse the repository at this point in the history
  • Loading branch information
rmisev committed Nov 5, 2024
1 parent 229a8c7 commit e12cb4e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions include/upa/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ template <typename Out, typename T,
#if defined(__clang__)
__attribute__((no_sanitize("unsigned-integer-overflow")))
#endif
inline Out checked_diff(T a, T b) {
constexpr Out checked_diff(T a, T b) {
if (a >= b) {
const UT diff = static_cast<UT>(static_cast<UT>(a) - static_cast<UT>(b));
if (diff <= unsigned_limit<Out>::max())
Expand Down Expand Up @@ -95,7 +95,7 @@ inline void unsigned_to_str(UIntT num, std::string& output, UIntT base) {

// Append data to string

inline std::size_t add_sizes(std::size_t size1, std::size_t size2, std::size_t max_size) {
constexpr std::size_t add_sizes(std::size_t size1, std::size_t size2, std::size_t max_size) {
if (max_size - size1 < size2)
throw std::length_error("too big size");
// now it is safe to add sizes
Expand Down

0 comments on commit e12cb4e

Please sign in to comment.