2
0
mirror of https://github.com/boostorg/hana.git synced 2026-02-15 01:02:10 +00:00

Logical: add not_

This commit is contained in:
Louis Dionne
2014-06-21 12:30:14 -04:00
parent 13e3bf02f6
commit 7b7bbd2290
16 changed files with 135 additions and 54 deletions

View File

@@ -0,0 +1,37 @@
/*
@copyright Louis Dionne 2014
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
*/
#include <boost/hana/logical.hpp>
#include <boost/hana/detail/constexpr.hpp>
#include <cassert>
using namespace boost::hana;
BOOST_HANA_CONSTEXPR_LAMBDA auto test = [](auto true_, auto false_) {
assert(eval_if(true_,
[=](auto) { return true_; },
[](auto id) { return 1 / id(0); }
) == true_);
assert(eval_if(false_,
[](auto id) { return 1 / id(0); },
[=](auto) { return false_; }
) == false_);
assert(if_(true_, true_, false_) == true_);
assert(if_(false_, true_, false_) == false_);
assert(not_(not_(true_)));
assert(not_(false_));
};
int main() {
test(true, false);
test(1, 0);
test(2ll, 0ll);
test(2, false);
}