//
// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
//
// The contents of this file are covered under the licence agreement in the
// file "LICENCE" distributed with Cforall.
//
// assert.h --
//
// Author           : Peter A. Buhr
// Created On       : Thu Aug 18 13:19:26 2016
// Last Modified By : Peter A. Buhr
// Last Modified On : Tue Aug  1 11:56:01 2017
// Update Count     : 16
//

#pragma once
// Pragmas for header cleanup tool
// IWYU pragma: private, include <cassert>

#include_next <cassert>

#ifdef NDEBUG

#define assertf(expr, fmt, ...) (__ASSERT_VOID_ASSERT (0))

#else

#define assertf(expr, fmt, ...) ((expr) \
	? (__ASSERT_VOID_CAST (0)) \
	: __assert_fail_f( #expr, __FILE__, __LINE__, \
	__ASSERT_FUNCTION, fmt, ## __VA_ARGS__ ))

void __assert_fail_f( 	const char *assertion, const char *file,
						unsigned int line, const char *function,
						const char *fmt, ...
	) __attribute__((noreturn, format(printf, 5, 6)));

#endif

template<typename T, typename U>
static inline T strict_dynamic_cast( const U & src ) {
	T ret = dynamic_cast<T>(src);
	assert(ret);
	return ret;
}

// Local Variables: //
// tab-width: 4 //
// mode: c++ //
// compile-command: "make install" //
// End: //
