diff --git a/source/mijin/util/exception.hpp b/source/mijin/util/exception.hpp new file mode 100644 index 0000000..b27f1f5 --- /dev/null +++ b/source/mijin/util/exception.hpp @@ -0,0 +1,30 @@ + +#pragma once + +#ifndef MIJIN_UTIL_EXCEPTION_HPP_INCLUDED +#define MIJIN_UTIL_EXCEPTION_HPP_INCLUDED 1 + +#include + +namespace mijin +{ + +// +// public defines +// + +// +// public functions +// + +template +inline decltype(auto) ensure(TCondition&& condition, TExceptionArgs&&... args) +{ + if (!static_cast(std::forward(condition))) + { + throw TException(std::forward(args)...); + } + return std::forward(condition); +} +} // namespace mijin +#endif // MIJIN_UTIL_EXCEPTION_HPP_INCLUDED