kblib 0.2.3
General utilities library for modern C++
logic.h
Go to the documentation of this file.
1/* *****************************************************************************
2 * kblib is a general utility library for C++14 and C++17, intended to provide
3 * performant high-level abstractions and more expressive ways to do simple
4 * things.
5 *
6 * Copyright (c) 2021 killerbee
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 * ****************************************************************************/
21
31#ifndef KBLIB_LOGIC_H
32#define KBLIB_LOGIC_H
33
34#include "tdecl.h"
35
36#include <type_traits>
37
38namespace KBLIB_NS {
39
44template <bool A, bool B>
45struct implies : std::integral_constant<bool, true> {};
46
50template <>
51struct implies<true, false> : std::integral_constant<bool, false> {};
52
53#if KBLIB_USE_CXX17
57template <bool A, bool B>
58constexpr inline bool implies_v = implies<A, B>::value;
59
60template <bool... args>
61constexpr inline bool conjunction_v = (args and ...);
62#endif
63
64} // namespace KBLIB_NS
65
66#endif // KBLIB_LOGIC_H
constexpr bool implies_v
Definition: logic.h:58
constexpr bool conjunction_v
Definition: logic.h:61
A metafunction for logical implication. That is, if A, then B. If not A, B is unimportant.
Definition: logic.h:45
Provides macros and basic templates used by the rest of kblib.
#define KBLIB_NS
Definition: tdecl.h:113