forked from Alepha/Alepha
45 lines
620 B
C++
45 lines
620 B
C++
static_assert( __cplusplus > 2023'00 );
|
|
|
|
#pragma once
|
|
|
|
#include <Alepha/Alepha.h>
|
|
|
|
#include <cassert>
|
|
|
|
namespace Alepha::Hydrogen ::detail:: Invariant_m
|
|
{
|
|
inline namespace exports
|
|
{
|
|
template< typename T >
|
|
class Invariant
|
|
{
|
|
private:
|
|
const T *this_;
|
|
|
|
void
|
|
check() const
|
|
{
|
|
assert( this_->invariant() );
|
|
}
|
|
|
|
public:
|
|
~Invariant()
|
|
{
|
|
check();
|
|
}
|
|
|
|
explicit
|
|
Invariant( const T *const this_ )
|
|
: this_( this_ )
|
|
{
|
|
check();
|
|
}
|
|
};
|
|
}
|
|
}
|
|
|
|
namespace Alepha::Hydrogen::inline exports::inline Invariant_m
|
|
{
|
|
using namespace detail::Invariant_m::exports;
|
|
}
|