1/*=============================================================================
2 Copyright (c) 2015 Paul Fultz II
3 and.h
4 Distributed under the Boost Software License, Version 1.0. (See accompanying
5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6==============================================================================*/
7
8#ifndef BOOST_HOF_GUARD_AND_H
9#define BOOST_HOF_GUARD_AND_H
10
11#include <type_traits>
12#include <boost/hof/detail/using.hpp>
13#include <boost/hof/detail/intrinsics.hpp>
14
15namespace boost { namespace hof { namespace detail {
16
17constexpr bool and_c()
18{
19 return true;
20}
21
22template<class... Ts>
23constexpr bool and_c(bool b, Ts... bs)
24{
25 return b && and_c(bs...);
26}
27
28#ifdef _MSC_VER
29
30template<class... Ts>
31struct and_;
32
33template<class T, class... Ts>
34struct and_<T, Ts...>
35: std::integral_constant<bool, (T::value && and_<Ts...>::value)>
36{};
37
38template<>
39struct and_<>
40: std::true_type
41{};
42
43#define BOOST_HOF_AND_UNPACK(Bs) (boost::hof::detail::and_c(Bs...))
44#else
45template<bool...> struct bool_seq {};
46template<class... Ts>
47BOOST_HOF_USING(and_, std::is_same<bool_seq<Ts::value...>, bool_seq<(Ts::value, true)...>>);
48
49#define BOOST_HOF_AND_UNPACK(Bs) BOOST_HOF_IS_BASE_OF(boost::hof::detail::bool_seq<Bs...>, boost::hof::detail::bool_seq<(Bs || true)...>)
50
51#endif
52
53}}} // namespace boost::hof
54
55#endif
56

source code of boost/libs/hof/include/boost/hof/detail/and.hpp