source: src/include/cassert @ d120290

ADTast-experimentalenumforall-pointer-decayjacob/cs343-translationpthread-emulationqualifiedEnum
Last change on this file since d120290 was dafe9e1, checked in by Andrew Beach <ajbeach@…>, 5 years ago

Fixed broken destructor cycles. Cleaned up strict_dynamic_cast.

  • Property mode set to 100644
File size: 1.6 KB
RevLine 
[12756de]1//
2// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
3//
4// The contents of this file are covered under the licence agreement in the
5// file "LICENCE" distributed with Cforall.
[4f147cc]6//
7// assert.h --
8//
[12756de]9// Author           : Peter A. Buhr
10// Created On       : Thu Aug 18 13:19:26 2016
[f685679]11// Last Modified By : Andrew Beach
[dafe9e1]12// Last Modified On : Mon Jun  3 13:11:00 2017
13// Update Count     : 18
[4f147cc]14//
15
16#pragma once
[bf2438c]17// Pragmas for header cleanup tool
18// IWYU pragma: private, include <cassert>
[12756de]19
[e59c088]20#include_next <cassert>
[12756de]21
[733074e]22#include <string>
23
24template < typename ... Params >
25std::string toString( const Params & ... params );
26
[e59c088]27#ifdef NDEBUG
[12756de]28
[e59c088]29#define assertf(expr, fmt, ...) (__ASSERT_VOID_ASSERT (0))
30
31#else
32
33#define assertf(expr, fmt, ...) ((expr) \
34        ? (__ASSERT_VOID_CAST (0)) \
35        : __assert_fail_f( #expr, __FILE__, __LINE__, \
36        __ASSERT_FUNCTION, fmt, ## __VA_ARGS__ ))
37
[e3e16bc]38void __assert_fail_f(   const char *assertion, const char *file,
39                                                unsigned int line, const char *function,
40                                                const char *fmt, ...
[e59c088]41        ) __attribute__((noreturn, format(printf, 5, 6)));
42
43#endif
[12756de]44
[dafe9e1]45template<typename T, typename U>
[f685679]46static inline T strict_dynamic_cast( const U & src ) {
[8abee136]47        assert(src);
[4f147cc]48        T ret = dynamic_cast<T>(src);
[be151bf]49        assertf(ret, "%s", toString(src).c_str());
[4f147cc]50        return ret;
51}
52
[dafe9e1]53template<typename T, decltype(nullptr) null, typename U>
54static inline T strict_dynamic_cast( const U & src ) {
55        return src ? strict_dynamic_cast<T, U>( src ) : nullptr;
56}
57
[6a625de]58extern void abort(const char *fmt, ...  ) noexcept __attribute__((noreturn, format(printf, 1, 2)));
[12756de]59// Local Variables: //
60// tab-width: 4 //
61// mode: c++ //
62// compile-command: "make install" //
63// End: //
Note: See TracBrowser for help on using the repository browser.