-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathcommand_internal.h
83 lines (69 loc) · 1.96 KB
/
command_internal.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//
// command_internal.h
//
#pragma once
#include "config.h"
#include <type_traits>
#if CB_COMMAND_PACKET_ALIGNED == 1
#define CB_COMMAND_PACKET_ALIGN() cb::detail::CommandPacketAlign<alignof(cb::CommandPacket)> alignment;
#else
#define CB_COMMAND_PACKET_ALIGN()
#endif
namespace cb
{
namespace detail
{
template <typename T, bool IsClass = false>
struct has_pod_hint_tag_impl
{
static const bool value = false;
};
template <typename T>
struct has_pod_hint_tag_impl<T, true>
{
struct fallback
{
typedef void pod_hint_tag;
};
struct derived : T, fallback
{
};
template <typename U>
struct check;
typedef char no[1];
typedef char yes[2];
template <typename U>
static no& test(check<typename U::pod_hint_tag>*);
template <typename U>
static yes& test(...);
public:
static const bool value = sizeof(test<derived>(0)) == sizeof(yes);
};
template <typename T>
struct has_pod_hint_tag : detail::has_pod_hint_tag_impl<T, std::is_class<T>::value>
{
typedef has_pod_hint_tag<T> type;
};
template <typename T, typename TT = void>
struct is_pod : std::integral_constant<bool, std::is_pod<T>::value | has_pod_hint_tag<T>::value>
{
static const bool value = std::is_pod<T>::value | has_pod_hint_tag<T>::value;
};
#if CB_COMMAND_PACKET_ALIGNED
template <int Alignment>
struct CommandPacketAlign
{
};
template <>
struct CommandPacketAlign<8>
{
uint64_t dummy;
};
template <>
struct CommandPacketAlign<4>
{
uint32_t dummy;
};
#endif // #if CB_COMMAND_PACKET_ALIGNED
} // namespace detail
} // namespace cb