2016-11-13 14:56:35 +00:00
|
|
|
// tasmet_assert.h
|
|
|
|
//
|
|
|
|
// Author: J.A. de Jong
|
|
|
|
//
|
|
|
|
// Description:
|
|
|
|
// Implementation of asserts
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
#pragma once
|
|
|
|
#ifndef TASMET_ASSERT_H
|
|
|
|
#define TASMET_ASSERT_H
|
|
|
|
#include <type_traits>
|
2016-12-02 13:31:10 +00:00
|
|
|
#ifndef TASMET_DEBUG
|
|
|
|
|
2016-11-13 14:56:35 +00:00
|
|
|
static_assert(false, "TASMET_DEBUG macro not defined. Please set it to 1 or 0");
|
2016-12-02 13:31:10 +00:00
|
|
|
|
2016-11-13 14:56:35 +00:00
|
|
|
#endif
|
|
|
|
|
2016-12-02 13:31:10 +00:00
|
|
|
// Compile-time type checking for template instantiation.
|
|
|
|
template<class T, class U>
|
|
|
|
struct is_same : std::false_type {};
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
struct is_same<T, T> : std::true_type {};
|
|
|
|
|
|
|
|
|
2016-11-13 14:56:35 +00:00
|
|
|
#if TASMET_DEBUG == 1
|
|
|
|
#include <cassert>
|
|
|
|
#include "tasmet_io.h"
|
|
|
|
|
|
|
|
void tasmet_assertfailed(const char* filename,size_t linenr,const char* statement);
|
|
|
|
|
2016-12-15 20:34:11 +00:00
|
|
|
#define tasmet_assert(assertion,txt) \
|
|
|
|
{ \
|
|
|
|
if (!(assertion)) \
|
|
|
|
{ \
|
2016-11-13 14:56:35 +00:00
|
|
|
tasmet_assertfailed(__FILE__, __LINE__, txt ); \
|
|
|
|
} \
|
2016-12-15 20:34:11 +00:00
|
|
|
}
|
2016-11-13 14:56:35 +00:00
|
|
|
|
|
|
|
#else
|
|
|
|
#define tasmet_assert(assertion,txt)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif // TASMET_ASSERT_H
|
|
|
|
//////////////////////////////////////////////////////////////////////
|