Skip to content

Commit

Permalink
Try DALI_ENFORCE as a function
Browse files Browse the repository at this point in the history
Signed-off-by: Krzysztof Lecki <[email protected]>
  • Loading branch information
klecki committed Mar 22, 2024
1 parent 9206d24 commit d63f66e
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion include/dali/core/error_handling.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include <utility>

#include "dali/core/common.h"
#include "dali/core/source_location.h"

namespace dali {

Expand Down Expand Up @@ -227,7 +228,16 @@ inline dali::string GetStacktrace() {
} \
} while (0)

#define DALI_ENFORCE(...) GET_MACRO(__VA_ARGS__, ENFRC_2, ENFRC_1)(__VA_ARGS__)
// #define DALI_ENFORCE(...) GET_MACRO(__VA_ARGS__, ENFRC_2, ENFRC_1)(__VA_ARGS__)

template <typename T>
void DALI_ENFORCE(T condition, const std::string &error_string = "",
source_location loc = source_location::current()) {
if (!condition) {
throw DALIException(error_string, make_string("[", loc.source_file(), ":", loc.line(), "]"),
dali::GetStacktrace());
}
}

// Enforces that the value of 'var' is in the range [lower, upper)
#define DALI_ENFORCE_IN_RANGE(var, lower, upper) \
Expand Down

0 comments on commit d63f66e

Please sign in to comment.