"test/vscode:/vscode.git/clone" did not exist on "b50d8b24e2563b11a8533d8d5a7a17600aaec82d"
requires.hpp 1.67 KB
Newer Older
Paul's avatar
Paul committed
1
2
#ifndef MIGRAPH_GUARD_MIGRAPHLIB_REQUIRES_HPP
#define MIGRAPH_GUARD_MIGRAPHLIB_REQUIRES_HPP
Paul's avatar
Paul committed
3
4

#include <type_traits>
5
#include <migraph/config.hpp>
Paul's avatar
Paul committed
6

7
8
namespace migraph {
inline namespace MIGRAPH_INLINE_NS {
Paul's avatar
Paul committed
9

Paul's avatar
Paul committed
10
template <bool... Bs>
Paul's avatar
Paul committed
11
struct and_ : std::is_same<and_<Bs...>, and_<(Bs || true)...>> // NOLINT
Paul's avatar
Paul committed
12
13
{
};
Paul's avatar
Paul committed
14

Paul's avatar
Paul committed
15
template <bool B>
Paul's avatar
Paul committed
16
17
using bool_c = std::integral_constant<bool, B>;

Paul's avatar
Paul committed
18
template <int N>
19
20
21
22
struct requires_enum
{
    enum e
    {
Paul's avatar
Paul committed
23
        a = 0
24
25
26
    };
};

Paul's avatar
Paul committed
27
#define MIGRAPH_REQUIRES_CAT(x, y) x##y
28

Paul's avatar
Paul committed
29
#ifdef CPPCHECK
Paul's avatar
Paul committed
30
#define MIGRAPH_REQUIRES(...) class = void
Paul's avatar
Paul committed
31
#else
32
#if 0
Paul's avatar
Paul committed
33
// TODO: This currently crashed on clang
Paul's avatar
Paul committed
34
35
36
#define MIGRAPH_REQUIRES(...)                                                                       \
    typename migraph::requires_enum<__LINE__>::e MIGRAPH_REQUIRES_CAT(                              \
        PrivateRequires,                                                                            \
Paul's avatar
Paul committed
37
        __LINE__) = migraph::requires_enum<__LINE__>::a,                                            \
Paul's avatar
Paul committed
38
39
        class     = typename std::enable_if<and_<__VA_ARGS__,                                       \
                                             MIGRAPH_REQUIRES_CAT(PrivateRequires, __LINE__) == \
Paul's avatar
Paul committed
40
                                                 migraph::requires_enum<__LINE__>::a>{}>::type
41
#else
Paul's avatar
Paul committed
42
43
#define MIGRAPH_REQUIRES(...)                                             \
    typename migraph::requires_enum<__LINE__>::e MIGRAPH_REQUIRES_CAT(    \
Paul's avatar
Paul committed
44
        PrivateRequires, __LINE__) = migraph::requires_enum<__LINE__>::a, \
Paul's avatar
Paul committed
45
                         class     = typename std::enable_if<and_<__VA_ARGS__>{}>::type
46
#endif
Paul's avatar
Paul committed
47
#endif
Paul's avatar
Paul committed
48

49
} // namespace MIGRAPH_INLINE_NS
Paul's avatar
Paul committed
50
} // namespace migraph
Paul's avatar
Paul committed
51
52

#endif