requires.hpp 567 Bytes
Newer Older
Paul's avatar
Paul committed
1
2
3
4
5
6
7
#ifndef RTG_GUARD_RTGLIB_REQUIRES_HPP
#define RTG_GUARD_RTGLIB_REQUIRES_HPP

#include <type_traits>

namespace rtg {

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

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

Paul's avatar
Paul committed
16
#ifdef CPPCHECK
Paul's avatar
Paul committed
17
#define RTG_REQUIRES(...) class = void
Paul's avatar
Paul committed
18
#else
Paul's avatar
Paul committed
19
20
21
#define RTG_REQUIRES(...)                  \
    bool PrivateRequires##__LINE__ = true, \
         class = typename std::enable_if<and_<__VA_ARGS__, PrivateRequires##__LINE__>{}>::type
Paul's avatar
Paul committed
22
#endif
Paul's avatar
Paul committed
23
24
25
26

} // namespace rtg

#endif