YPC
0.2.0
include
ypc
core_t
analyzer
helper
ecall_impl_helper.h
1
#pragma once
2
#include <type_traits>
3
4
#define decl_feature_helper(feature, funcname, ret, ...) \
5
template <typename, typename T> struct has_##feature { \
6
static constexpr bool value = false; \
7
}; \
8
template <typename C, typename Ret, typename... Args> \
9
struct has_##feature<C, Ret(Args...)> { \
10
private: \
11
template <typename T> \
12
static constexpr auto check(T *) -> typename std::is_same< \
13
decltype(std::declval<T>().funcname(std::declval<Args>()...)), \
14
Ret>::type; \
15
\
16
template <typename> static constexpr std::false_type check(...); \
17
\
18
typedef decltype(check<C>(0)) type; \
19
\
20
public: \
21
static constexpr bool value = type::value; \
22
}; \
23
template <typename C, bool contains_##feature = \
24
has_##feature<C, ret(__VA_ARGS__)>::value> \
25
struct call_##feature##_helper { \
26
template <typename... ARGS> static ret call(C &obj, ARGS &&... args) { \
27
return obj.funcname(args...); \
28
} \
29
}; \
30
template <typename C> struct call_##feature##_helper<C, false> { \
31
template <typename... ARGS> static ret call(C &obj, ARGS &&... args) { \
32
return stbox::stx_status::no_such_feature; \
33
} \
34
};
35
36
decl_feature_helper(init_model, init_model, uint32_t,
const
uint8_t *,
37
uint32_t);
38
decl_feature_helper(init_data_source, init_data_source, uint32_t,
39
const
uint8_t *, uint32_t);
40
Generated by
1.8.17