AsmGrader 0.0.0
Loading...
Searching...
No Matches
count_if.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cstddef>
4#include <type_traits>
5
6namespace asmgrader {
7
8// TODO: Use boost::mp11::mp_count_if instead
9
10template <template <typename> typename Cond, typename... Ts>
12{
13 static constexpr std::size_t value = (Cond<Ts>::value + ... + 0);
14};
15
16template <template <typename> typename Cond, typename... Ts>
17constexpr std::size_t count_if_v = count_if<Cond, Ts...>::value;
18
19template <template <typename> typename Cond, typename... Ts>
21{
22 static constexpr std::size_t value = sizeof...(Ts) - (Cond<Ts>::value + ... + 0);
23};
24
25template <template <typename> typename Cond, typename... Ts>
26constexpr std::size_t count_if_not_v = count_if_not<Cond, Ts...>::value;
27
30static_assert(count_if_v<std::is_integral> == 0);
31
32} // namespace asmgrader
Definition asm_buffer.hpp:19
constexpr std::size_t count_if_v
Definition count_if.hpp:17
constexpr std::size_t count_if_not_v
Definition count_if.hpp:26
Definition count_if.hpp:21
static constexpr std::size_t value
Definition count_if.hpp:22
Definition count_if.hpp:12
static constexpr std::size_t value
Definition count_if.hpp:13