added new sanity checks and compile-time assertions to prevent errors

fixed stair-building issue
new test-cases
added elevator support
fixed/improved some walker modules
This commit is contained in:
2016-09-10 15:12:39 +02:00
parent 7baeecb3f9
commit 82f8828a04
26 changed files with 996 additions and 198 deletions

View File

@@ -67,7 +67,6 @@ namespace Assert {
if (std::abs(v1-v2) > delta) {doThrow(err);}
}
template <typename T, typename STR> static inline void isBetween(const T v, const T min, const T max, const STR err) {
if (v < min || v > max) {
std::stringstream ss; ss << "\n[" << min << ":" << max << "] but is " << v << "\n";
@@ -77,4 +76,24 @@ namespace Assert {
}
namespace StaticAssert {
// yes and no have a different size so sizeof(yes) != sizeof(no)
using yes = uint32_t;
using no = uint64_t;
template<class BaseClass, class SubClass> struct isXbaseOfY {
static yes test(const BaseClass&); // will be chosen if X is base of Y
static no test(...); // will be chosen otherwise
static const SubClass& helper();
static const bool value = sizeof(test(helper())) == sizeof(yes); // true if test(const B&) was chosen
};
template <typename A, typename B> static inline void AinheritsB() {
static_assert(isXbaseOfY<B, A>::value, "A does not inherit from B!");
}
}
#endif // ASSERTIONS_H