github.com/kaydxh/golang@v0.0.131/pkg/gocv/cgo/third_path/opencv4/include/opencv2/gapi/util/throw.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 Intel Corporation 6 7 8 #ifndef OPENCV_GAPI_UTIL_THROW_HPP 9 #define OPENCV_GAPI_UTIL_THROW_HPP 10 11 #include <utility> // std::forward 12 13 #if !defined(__EXCEPTIONS) 14 #include <stdlib.h> 15 #include <stdio.h> 16 #endif 17 18 namespace cv 19 { 20 namespace util 21 { 22 template <class ExceptionType> 23 [[noreturn]] void throw_error(ExceptionType &&e) 24 { 25 #if defined(__EXCEPTIONS) || defined(_CPPUNWIND) 26 throw std::forward<ExceptionType>(e); 27 #else 28 fprintf(stderr, "An exception thrown! %s\n" , e.what()); 29 fflush(stderr); 30 abort(); 31 #endif 32 } 33 } // namespace util 34 } // namespace cv 35 36 #endif // OPENCV_GAPI_UTIL_THROW_HPP