/* * Copyright (C) 2014 Pavel Kirienko */ #pragma once #include namespace uavcan { /** * Usage: * StaticAssert::check(); */ template struct StaticAssert; template <> struct StaticAssert { static void check() { } }; /** * Usage: * ShowIntegerAsError::foobar(); */ template struct ShowIntegerAsError; /** * Prevents copying when inherited */ class Noncopyable { Noncopyable(const Noncopyable&); Noncopyable& operator=(const Noncopyable&); protected: Noncopyable() { } }; /** * Compile time conditions */ template struct EnableIf { }; template struct EnableIf { typedef T Type; }; template struct EnableIfType { typedef R Type; }; template struct StaticIf; template struct StaticIf { typedef TrueType Result; }; template struct StaticIf { typedef FalseType Result; }; /** * Value types */ template struct BooleanType { }; typedef BooleanType TrueType; typedef BooleanType FalseType; /** * Makeshift binder */ template class MethodBinder { ObjectPtr obj_; MemFunPtr fun_; public: MethodBinder(ObjectPtr o, MemFunPtr f) : obj_(o), fun_(f) { } void operator()() { (obj_->*fun_)(); } template void operator()(Par1 p1) { (obj_->*fun_)(p1); } template void operator()(Par1 p1, Par2 p2) { (obj_->*fun_)(p1, p2); } }; } /// Ensure that conditional comilation macros are present #include