// // require.hpp // gameutils // // Created by Sam Jaffe on 8/19/16. // #pragma once #include #include "macro.h" inline namespace precondition { template void _expect(bool expr, char const * message) { if (!expr) throw except{message}; } } #if defined( __clang__ ) || defined( __GNUC__ ) # define LOCATION_INFO ". in " STRING(__PRETTY_FUNCTION__) "(" __FILE__ ":" STRING(__LINE__) ")" #elif defined( _MSC_VER ) # define LOCATION_INFO ". in " __FUNCTION__ "(" __FILE__ ":" STRING(__LINE__) ")" #else # define LOCATION_INFO ". in " __FILE__ ":" STRING(__LINE__) #endif #define error_msg(expr, msg) msg ": " #expr LOCATION_INFO #define expects(expr, msg) expects_e(expr, std::logic_error, msg) #define expects_e(expr, except, msg) precondition::_expect( expr, error_msg(expr, msg) )