pputl  0.2.1
pputl Preprocessor Utilities
includes.h
Go to the documentation of this file.
1 #ifndef PPUTL_INCLUDES_H_INCLUDED
2 #define PPUTL_INCLUDES_H_INCLUDED
3 #///// c++20
4 #///////////////////////////////////////////////////////////////////////////////
5 #/// @brief \link PPUTL_INCLUDES PPUTL_INCLUDES\endlink -
6 #/// expands to 1 if numeric args [0, 256) have at least one `n` value; else 0
7 #/// @file
8 #// __ ___
9 #// /\ \__/\_ \
10 #// _____ _____ __ __\ \ ,_\//\ \
11 #// /\ '__`\/\ '__`\/\ \/\ \\ \ \/ \ \ \
12 #// \ \ \_\ \ \ \_\ \ \ \_\ \\ \ \_ \_\ \_
13 #// \ \ ,__/\ \ ,__/\ \____/ \ \__\/\____\
14 #// \ \ \ \ \ \ \/___/ \/__/\/____/
15 #// \/_/ \/_/
16 #//
17 #// pputl Preprocessor Utilities
18 #// Copyright (C) 2020 Justin Collier <m@jpcx.dev>
19 #//
20 #// This program is free software: you can redistribute it and/or modify
21 #// it under the terms of the GNU General Public License as published by
22 #// the Free Software Foundation, either version 3 of the License, or
23 #// (at your option) any later version.
24 #//
25 #// This program is distributed in the hope that it will be useful,
26 #// but WITHOUT ANY WARRANTY; without even the internalied warranty of
27 #// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 #// GNU General Public License for more details.
29 #// //
30 #// You should have received a copy of the GNU General Public License ///
31 #// along with this program. If not, see <https://www.gnu.org/licenses/>. ////
32 #///////////////////////////////////////////////////////////////////////////////
33 #
34 #include "pputl/cat.h"
35 #include "pputl/eq.h"
36 #include "pputl/expand.h"
37 #include "pputl/iif.h"
38 #include "pputl/reduce.h"
39 #include "pputl/tuple/elem.h"
40 #
41 #/// expands to 1 if numeric args [0, 256) have at least one `n` value; else 0
42 #/// @ingroup pputl
43 #/// @anchor PPUTL_INCLUDES
44 #/// @param n number to check for
45 #/// @param ... numeric args; all values and total size ranged [0, 256)
46 #define PPUTL_INCLUDES(n, ...)
48  1, PPUTL_REDUCE(PPUTL_DETAIL_INCLUDES_REDUCER, (n, 0), __VA_ARGS__))
49 #
50 #define PPUTL_DETAIL_INCLUDES_REDUCER(a, v, i)
51  PPUTL_IIF(PPUTL_TUPLE_ELEM(1, a))
52  (a, PPUTL_IIF(PPUTL_EQ(v, PPUTL_TUPLE_ELEM(0, a)))(
53  (PPUTL_TUPLE_ELEM(0, a), 1), (PPUTL_TUPLE_ELEM(0, a), 0)))
54 #
55 #endif
PPUTL_DETAIL_INCLUDES_REDUCER
#define PPUTL_DETAIL_INCLUDES_REDUCER(a, v, i)
Definition: includes.h:50
PPUTL_TUPLE_ELEM
#define PPUTL_TUPLE_ELEM(idx, tup)
Definition: elem.h:41
PPUTL_REDUCE
#define PPUTL_REDUCE(reducer, initial,...)
Definition: reduce.h:57