pputl  0.2.1
pputl Preprocessor Utilities
eq.h
Go to the documentation of this file.
1 #ifndef PPUTL_EQ_H_INCLUDED
2 #define PPUTL_EQ_H_INCLUDED
3 #///// c++20
4 #///////////////////////////////////////////////////////////////////////////////
5 #/// @brief \link PPUTL_EQ PPUTL_EQ\endlink -
6 #/// expands to 1 if two numbers a and b [0, 256) are equal, or 0 if not
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/choose.h"
35 #include "pputl/gen/repeat.h"
36 #
37 #/// expands to 1 if two numbers a and b [0, 256) are equal, or 0 if not
38 #/// @ingroup pputl
39 #/// @anchor PPUTL_EQ
40 #/// @param a number [0, 256)
41 #/// @param b number [0, 256)
42 #define PPUTL_EQ(a, b) PPUTL_DETAIL_EQ_X(a, b)
43 #
44 #define PPUTL_DETAIL_EQ_X(a, b)
45  PPUTL_CHOOSE(a)(PPUTL_DETAIL_EQ_BITS_CHOICE(b)(b))
46 #define PPUTL_DETAIL_EQ_BITS_CHOICE(i)
47  PPUTL_CHOOSE(i)
49 #
50 #define PPUTL_DETAIL_EQ_BITS_EQ0(i) 1, PPUTL_GEN_REPEAT(255, 0)
51 #define PPUTL_DETAIL_EQ_BITS_GT0(i)
52  PPUTL_GEN_REPEAT(i, 0), 1, PPUTL_GEN_REPEAT(254, 0)
53 #
54 #endif
PPUTL_DETAIL_EQ_X
#define PPUTL_DETAIL_EQ_X(a, b)
Definition: eq.h:44
PPUTL_DETAIL_EQ_BITS_EQ0
#define PPUTL_DETAIL_EQ_BITS_EQ0(i)
Definition: eq.h:50
PPUTL_CHOOSE
#define PPUTL_CHOOSE(idx)
Definition: choose.h:47
PPUTL_GEN_REPEAT
#define PPUTL_GEN_REPEAT(n,...)
Definition: repeat.h:43
PPUTL_DETAIL_EQ_BITS_GT0
#define PPUTL_DETAIL_EQ_BITS_GT0(i)
Definition: eq.h:51