Skip to content

Commit 72165bd

Browse files
committed
Added if_m
1 parent a037edb commit 72165bd

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

internals/testing/compile_only_test.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,10 @@ static_assert(!is_stored_plain_v<char *>);
4848
static_assert(is_stored_plain_v<int *>);
4949
static_assert(is_stored_plain_v<int * [2]>);
5050

51+
static_assert(lax::value_of_v<lax::if_m<lax::and_m<>, lax::value_t<int, 1>,
52+
lax::value_t<int, 2>>> == 1);
53+
54+
static_assert(lax::value_of_v<lax::if_m<lax::or_m<>, lax::value_t<int, 1>,
55+
lax::value_t<int, 2>>> == 2);
56+
5157
int main() { return 0; }

provides/include/lax_v1/logical.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@
44
#include "lax_v1/logical_synopsis.hpp"
55
#include "lax_v1/value.hpp"
66

7+
template <class ElseExpr> struct lax_v1::if_m<ElseExpr> : force_t<ElseExpr> {};
8+
template <class CondExpr, class ThenExpr, class... ElseExprs>
9+
struct lax_v1::if_m<CondExpr, ThenExpr, ElseExprs...>
10+
: if_m<force_t<CondExpr>, ThenExpr, ElseExprs...> {};
11+
template <class ThenExpr, class... ElseExprs>
12+
struct lax_v1::if_m<lax_v1::true_t, ThenExpr, ElseExprs...> : ThenExpr {};
13+
template <class ThenExpr, class... ElseExprs>
14+
struct lax_v1::if_m<lax_v1::false_t, ThenExpr, ElseExprs...>
15+
: if_m<ElseExprs...> {};
16+
717
template <> struct lax_v1::and_m<> : true_t {};
818
template <class... Exprs>
919
struct lax_v1::and_m<lax_v1::false_t, Exprs...> : false_t {};

provides/include/lax_v1/logical_synopsis.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace lax_v1 {
44

5+
template <class... Exprs> struct if_m;
6+
57
template <class... Exprs> struct and_m;
68

79
template <class Expr> struct not_m;

0 commit comments

Comments
 (0)