github.com/kaydxh/golang@v0.0.131/pkg/gocv/cgo/third_path/opencv4/include/opencv2/gapi/own/assert.hpp (about) 1 // This file is part of OpenCV project. 2 // It is subject to the license terms in the LICENSE file found in the top-level directory 3 // of this distribution and at http://opencv.org/license.html. 4 // 5 // Copyright (C) 2018-2020 Intel Corporation 6 7 8 #ifndef OPENCV_GAPI_OWN_ASSERT_HPP 9 #define OPENCV_GAPI_OWN_ASSERT_HPP 10 11 #include <opencv2/gapi/util/compiler_hints.hpp> 12 13 #define GAPI_DbgAssertNoOp(expr) { \ 14 constexpr bool _assert_tmp = false && (expr); \ 15 cv::util::suppress_unused_warning(_assert_tmp); \ 16 } 17 18 #if !defined(GAPI_STANDALONE) 19 #include <opencv2/core/base.hpp> 20 #define GAPI_Assert CV_Assert 21 22 #if defined _DEBUG || defined CV_STATIC_ANALYSIS 23 # define GAPI_DbgAssert CV_DbgAssert 24 #else 25 # define GAPI_DbgAssert(expr) GAPI_DbgAssertNoOp(expr) 26 #endif 27 28 #else 29 #include <stdexcept> 30 #include <sstream> 31 #include <opencv2/gapi/util/throw.hpp> 32 33 namespace detail 34 { 35 [[noreturn]] inline void assert_abort(const char* str, int line, const char* file, const char* func) 36 { 37 std::stringstream ss; 38 ss << file << ":" << line << ": Assertion " << str << " in function " << func << " failed\n"; 39 cv::util::throw_error(std::logic_error(ss.str())); 40 } 41 } 42 43 #define GAPI_Assert(expr) \ 44 { if (!(expr)) ::detail::assert_abort(#expr, __LINE__, __FILE__, __func__); } 45 46 47 #ifdef NDEBUG 48 # define GAPI_DbgAssert(expr) GAPI_DbgAssertNoOp(expr) 49 #else 50 # define GAPI_DbgAssert(expr) GAPI_Assert(expr) 51 #endif 52 53 #endif // GAPI_STANDALONE 54 55 #endif // OPENCV_GAPI_OWN_ASSERT_HPP