|
| 1 | +#include "lax_v1/arithmetic.hpp" |
| 2 | +#include "lax_v1/comparison.hpp" |
| 3 | +#include "lax_v1/functional.hpp" |
| 4 | +#include "lax_v1/type_traits.hpp" |
| 5 | + |
| 6 | +#include "config.hpp" |
| 7 | + |
| 8 | +static_assert(lax::apply_m<lax::compose_m<lax::neg_m<>, lax::neg_m<>>, |
| 9 | + lax::auto_c<2>>::value == 2); |
| 10 | + |
| 11 | +static_assert(lax::apply_m<lax::composes_m<lax::add_m<lax::auto_c<1>>, |
| 12 | + lax::neg_m<>, |
| 13 | + lax::add_m<lax::auto_c<-1>>>, |
| 14 | + lax::auto_c<1>>::value == 1); |
| 15 | + |
| 16 | +static_assert(lax::apply_m<lax::pipes_m<lax::add_m<lax::auto_c<1>>, |
| 17 | + lax::neg_m<>, |
| 18 | + lax::add_m<lax::auto_c<-1>>>, |
| 19 | + lax::auto_c<1>>::value == -3); |
| 20 | + |
| 21 | +static_assert(lax::thru_m<lax::auto_c<1>, |
| 22 | + lax::add_m<lax::auto_c<1>>, |
| 23 | + lax::neg_m<>, |
| 24 | + lax::add_m<lax::auto_c<-1>>, |
| 25 | + lax::eq_m<lax::auto_c<-3>>>::value == true); |
| 26 | + |
| 27 | +struct V; |
| 28 | + |
| 29 | +static_assert(lax::apply_m<lax::function_c<V, lax::add_m<V, lax::neg_m<V>>>, |
| 30 | + lax::auto_c<1>>::value == 0); |
| 31 | + |
| 32 | +static_assert(lax::thru_m<lax::type_c<short * [1]>, |
| 33 | + lax::remove_all_extents_m<>, |
| 34 | + lax::remove_pointer_m<>, |
| 35 | + lax::alignment_of_m<>>::value == alignof(short)); |
| 36 | + |
| 37 | +static_assert(lax::thru_m<lax::auto_c<0>, |
| 38 | + lax::div_m<lax::auto_c<0>>, |
| 39 | + lax::constant_m<lax::auto_c<101>>>::value == 101); |
| 40 | + |
| 41 | +template <class T> |
| 42 | +using adhoc_t = lax::as_type_trait_t< |
| 43 | + lax::pipe_m<lax::remove_all_extents_m<>, lax::remove_pointer_m<>>, |
| 44 | + T>; |
| 45 | + |
| 46 | +static_assert(std::is_same_v<adhoc_t<int * [2][2]>, int>); |
| 47 | + |
| 48 | +template <class T> |
| 49 | +inline constexpr auto adhoc_v = lax::as_value_trait_v< |
| 50 | + lax::pipe_m<lax::remove_all_extents_m<>, lax::alignment_of_m<>>, |
| 51 | + T>; |
| 52 | + |
| 53 | +static_assert(adhoc_v<int * [2][2]> == alignof(int *)); |
| 54 | + |
| 55 | +struct F; |
| 56 | + |
| 57 | +using factorial_m = lax::fix_m<lax::fn_c< |
| 58 | + lax::seq_c<F, V>, |
| 59 | + lax::if_m<lax::eq_m<lax::auto_c<0>, V>, |
| 60 | + lax::auto_c<1>, |
| 61 | + lax::mul_m<V, lax::apply_m<F, lax::sub_m<V, lax::auto_c<1>>>>>>>; |
| 62 | + |
| 63 | +static_assert(lax::apply_m<factorial_m, lax::auto_c<5>>::value == 120); |
0 commit comments