UAVCAN_EXPORT

This commit is contained in:
Pavel Kirienko
2014-04-08 15:40:51 +04:00
parent 159b14e129
commit e8fa4a2369
55 changed files with 187 additions and 153 deletions
+25 -21
View File
@@ -4,6 +4,8 @@
#pragma once
#include <uavcan/impl_constants.hpp>
namespace uavcan
{
/**
@@ -11,10 +13,10 @@ namespace uavcan
* StaticAssert<expression>::check();
*/
template <bool Value>
struct StaticAssert;
struct UAVCAN_EXPORT StaticAssert;
template <>
struct StaticAssert<true>
struct UAVCAN_EXPORT StaticAssert<true>
{
static void check() { }
};
@@ -28,7 +30,7 @@ template <long N> struct ShowIntegerAsError;
/**
* Prevents copying when inherited
*/
class Noncopyable
class UAVCAN_EXPORT Noncopyable
{
Noncopyable(const Noncopyable&);
Noncopyable& operator=(const Noncopyable&);
@@ -40,33 +42,33 @@ protected:
* Compile time conditions
*/
template <bool B, typename T = void>
struct EnableIf { };
struct UAVCAN_EXPORT EnableIf { };
template <typename T>
struct EnableIf<true, T>
struct UAVCAN_EXPORT EnableIf<true, T>
{
typedef T Type;
};
template <typename T, typename R = void>
struct EnableIfType
struct UAVCAN_EXPORT EnableIfType
{
typedef R Type;
};
template <bool Condition, typename TrueType, typename FalseType>
struct Select;
struct UAVCAN_EXPORT Select;
template <typename TrueType, typename FalseType>
struct Select<true, TrueType, FalseType>
struct UAVCAN_EXPORT Select<true, TrueType, FalseType>
{
typedef TrueType Result;
};
template <typename TrueType, typename FalseType>
struct Select<false, TrueType, FalseType>
struct UAVCAN_EXPORT Select<false, TrueType, FalseType>
{
typedef FalseType Result;
};
@@ -74,7 +76,7 @@ struct Select<false, TrueType, FalseType>
/**
* Value types
*/
template <bool> struct BooleanType { };
template <bool> struct UAVCAN_EXPORT BooleanType { };
typedef BooleanType<true> TrueType;
typedef BooleanType<false> FalseType;
@@ -82,7 +84,7 @@ typedef BooleanType<false> FalseType;
* Relations
*/
template <typename T1, typename T2>
class IsImplicitlyConvertibleFromTo
class UAVCAN_EXPORT IsImplicitlyConvertibleFromTo
{
template <typename U> static U returner();
@@ -98,13 +100,14 @@ public:
template <typename From, typename To>
struct TryImplicitCastImpl
struct UAVCAN_EXPORT TryImplicitCastImpl
{
static To impl(const From& from, const To&, TrueType) { return To(from); }
static To impl(const From&, const To& default_, FalseType) { return default_; }
};
template <typename To, typename From>
UAVCAN_EXPORT
To try_implicit_cast(const From& from, const To& default_)
{
return TryImplicitCastImpl<From, To>::impl(from, default_,
@@ -112,6 +115,7 @@ To try_implicit_cast(const From& from, const To& default_)
}
template <typename To, typename From>
UAVCAN_EXPORT
To try_implicit_cast(const From& from)
{
return TryImplicitCastImpl<From, To>::impl(from, To(),
@@ -121,14 +125,14 @@ To try_implicit_cast(const From& from)
/**
* Some arithmetics
*/
template <unsigned Value> struct CompileTimeIntSqrt;
template <> struct CompileTimeIntSqrt<4> { enum { Result = 2 }; };
template <> struct CompileTimeIntSqrt<9> { enum { Result = 3 }; };
template <> struct CompileTimeIntSqrt<16> { enum { Result = 4 }; };
template <> struct CompileTimeIntSqrt<25> { enum { Result = 5 }; };
template <> struct CompileTimeIntSqrt<36> { enum { Result = 6 }; };
template <> struct CompileTimeIntSqrt<49> { enum { Result = 7 }; };
template <> struct CompileTimeIntSqrt<64> { enum { Result = 8 }; };
template <> struct CompileTimeIntSqrt<81> { enum { Result = 9 }; };
template <unsigned Value> struct UAVCAN_EXPORT CompileTimeIntSqrt;
template <> struct UAVCAN_EXPORT CompileTimeIntSqrt<4> { enum { Result = 2 }; };
template <> struct UAVCAN_EXPORT CompileTimeIntSqrt<9> { enum { Result = 3 }; };
template <> struct UAVCAN_EXPORT CompileTimeIntSqrt<16> { enum { Result = 4 }; };
template <> struct UAVCAN_EXPORT CompileTimeIntSqrt<25> { enum { Result = 5 }; };
template <> struct UAVCAN_EXPORT CompileTimeIntSqrt<36> { enum { Result = 6 }; };
template <> struct UAVCAN_EXPORT CompileTimeIntSqrt<49> { enum { Result = 7 }; };
template <> struct UAVCAN_EXPORT CompileTimeIntSqrt<64> { enum { Result = 8 }; };
template <> struct UAVCAN_EXPORT CompileTimeIntSqrt<81> { enum { Result = 9 }; };
}
@@ -16,7 +16,7 @@ namespace uavcan
{
template <typename T>
class LazyConstructor
class UAVCAN_EXPORT LazyConstructor
{
union
{
@@ -12,7 +12,7 @@ namespace uavcan
{
template <typename ObjectPtr, typename MemFunPtr>
class MethodBinder
class UAVCAN_EXPORT MethodBinder
{
ObjectPtr obj_;
MemFunPtr fun_;