Implement conjunction, disjunction, negation

This commit is contained in:
Glen Fernandes
2020-05-31 02:47:41 -04:00
parent bd5bede326
commit f8e9879d4e
11 changed files with 315 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
/*
Copyright 2020 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License,
Version 1.0. (See accompanying file LICENSE_1_0.txt
or copy at http://www.boost.org/LICENSE_1_0.txt)
*/
#ifdef TEST_STD
#include <type_traits>
#else
#include <boost/type_traits/conjunction.hpp>
#endif
#include "check_integral_constant.hpp"
template<int V>
struct Int {
static const int value = V;
};
TT_TEST_BEGIN(conjunction)
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::conjunction<Int<2>, Int<4> >::value), 4);
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::conjunction<Int<0>, Int<4> >::value), 0);
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::conjunction<Int<2>, Int<4>, Int<6>,
Int<8>, Int<10> >::value), 10);
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::conjunction<Int<2>, Int<0>, Int<4>,
Int<6>, Int<8> >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::conjunction<Int<4> >::value, 4);
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::conjunction<>::value, true);
#endif
TT_TEST_END
+35
View File
@@ -0,0 +1,35 @@
/*
Copyright 2020 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License,
Version 1.0. (See accompanying file LICENSE_1_0.txt
or copy at http://www.boost.org/LICENSE_1_0.txt)
*/
#ifdef TEST_STD
#include <type_traits>
#else
#include <boost/type_traits/disjunction.hpp>
#endif
#include "check_integral_constant.hpp"
template<int V>
struct Int {
static const int value = V;
};
TT_TEST_BEGIN(disjunction)
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::disjunction<Int<2>, Int<4> >::value), 2);
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::disjunction<Int<0>, Int<4> >::value), 4);
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::disjunction<Int<2>, Int<4>, Int<6>,
Int<8>, Int<10> >::value), 2);
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::disjunction<Int<0>, Int<0>, Int<6>,
Int<0>, Int<0> >::value), 6);
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::disjunction<Int<4> >::value, 4);
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::disjunction<>::value, false);
#endif
TT_TEST_END
+26
View File
@@ -0,0 +1,26 @@
/*
Copyright 2020 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License,
Version 1.0. (See accompanying file LICENSE_1_0.txt
or copy at http://www.boost.org/LICENSE_1_0.txt)
*/
#ifdef TEST_STD
#include <type_traits>
#else
#include <boost/type_traits/negation.hpp>
#endif
#include "check_integral_constant.hpp"
template<int V>
struct Int {
static const int value = V;
};
TT_TEST_BEGIN(negation)
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::negation<Int<5> >::value, false);
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::negation<Int<0> >::value, true);
TT_TEST_END