mirror of
https://github.com/NGSolve/netgen.git
synced 2025-02-24 21:15:41 +05:00
ThrowRangeException with [[noreturn]]
This commit is contained in:
parent
3c9f98b38d
commit
487942bc22
@ -55,8 +55,8 @@ namespace ngcore
|
|||||||
const char* what() const noexcept override { return m_what.c_str(); }
|
const char* what() const noexcept override { return m_what.c_str(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
NGCORE_API void ThrowException(const std::string & s);
|
[[noreturn]] NGCORE_API void ThrowException(const std::string & s);
|
||||||
NGCORE_API void ThrowException(const char * s);
|
[[noreturn]] NGCORE_API void ThrowException(const char * s);
|
||||||
|
|
||||||
// Out of Range exception
|
// Out of Range exception
|
||||||
class NGCORE_API RangeException : public Exception
|
class NGCORE_API RangeException : public Exception
|
||||||
@ -84,8 +84,8 @@ namespace ngcore
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
NGCORE_API void ThrowRangeException(const char * s, int ind, int imin, int imax);
|
[[noreturn]] NGCORE_API void ThrowRangeException(const char * s, int ind, int imin, int imax);
|
||||||
NGCORE_API void ThrowNotTheSameException(const char * s, long int a, long int b);
|
[[noreturn]] NGCORE_API void ThrowNotTheSameException(const char * s, long int a, long int b);
|
||||||
|
|
||||||
|
|
||||||
// Exception used if no simd implementation is available to fall back to standard evaluation
|
// Exception used if no simd implementation is available to fall back to standard evaluation
|
||||||
@ -99,21 +99,21 @@ namespace ngcore
|
|||||||
// Convenience macro to append file name and line of exception origin to the string
|
// Convenience macro to append file name and line of exception origin to the string
|
||||||
#define NG_EXCEPTION(s) ngcore::Exception(__FILE__ ":" NETGEN_CORE_NGEXEPTION_STR(__LINE__) "\t"+std::string(s))
|
#define NG_EXCEPTION(s) ngcore::Exception(__FILE__ ":" NETGEN_CORE_NGEXEPTION_STR(__LINE__) "\t"+std::string(s))
|
||||||
|
|
||||||
// template <typename T> constexpr bool IsSave() { return false; }
|
|
||||||
template <typename T>
|
|
||||||
struct IsSave
|
|
||||||
{
|
|
||||||
constexpr operator bool() const { return false; }
|
|
||||||
};
|
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct IsSafe {
|
||||||
|
constexpr operator bool() const { return false; } };
|
||||||
|
|
||||||
#if defined(NETGEN_ENABLE_CHECK_RANGE) && !defined(__CUDA_ARCH__)
|
#if defined(NETGEN_ENABLE_CHECK_RANGE) && !defined(__CUDA_ARCH__)
|
||||||
#define NETGEN_CHECK_RANGE(value, min, max_plus_one) \
|
#define NETGEN_CHECK_RANGE(value, min, max_plus_one) \
|
||||||
{ if constexpr (!IsSave<decltype(value)>()) if ((value)<(min) || (value)>=(max_plus_one)) \
|
{ if constexpr (!IsSafe<decltype(value)>()) { \
|
||||||
ThrowRangeException(__FILE__ ":" NETGEN_CORE_NGEXEPTION_STR(__LINE__) "\t", int(value), int(min), int(max_plus_one)); }
|
if ((value)<(min) || (value)>=(max_plus_one)) \
|
||||||
|
ThrowRangeException(__FILE__ ":" NETGEN_CORE_NGEXEPTION_STR(__LINE__) "\t", int(value), int(min), int(max_plus_one)); } }
|
||||||
|
|
||||||
// #define NETGEN_CHECK_SHAPE(a,b) \
|
// #define NETGEN_CHECK_SHAPE(a,b) \
|
||||||
// { if(a.Shape() != b.Shape()) \
|
// { if(a.Shape() != b.Shape()) \
|
||||||
// ngcore::ThrowException(__FILE__ ":" NETGEN_CORE_NGEXEPTION_STR(__LINE__) "\t: shapes don't match"); }
|
// ngcore::ThrowException(__FILE__ ":" NETGEN_CORE_NGEXEPTION_STR(__LINE__) "\t: shapes don't match"); }
|
||||||
|
|
||||||
#define NETGEN_CHECK_SAME(a,b) \
|
#define NETGEN_CHECK_SAME(a,b) \
|
||||||
{ if(a != b) { \
|
{ if(a != b) { \
|
||||||
if constexpr(std::is_same<decltype(a),size_t>() && std::is_same<decltype(b),size_t>()) \
|
if constexpr(std::is_same<decltype(a),size_t>() && std::is_same<decltype(b),size_t>()) \
|
||||||
|
Loading…
Reference in New Issue
Block a user