Pretty Good Sum Type  1.0.0
logical.hpp
Go to the documentation of this file.
1 #if !defined (LOGICAL_70B10597_2771_496C_9203_4CD3986547F1_H)
2 # define LOGICAL_70B10597_2771_496C_9203_4CD3986547F1_H
3 
4 # include <type_traits>
5 
12 
13 namespace pgs {
14 
29 
30 template<class F, class Acc, class... Ts>
31 struct fold_left : Acc {
32 };
33 
35 
36 template <class F, class Acc, class T, class... Ts>
37 struct fold_left<F, Acc, T, Ts...> :
38  fold_left <F, typename F::template apply<Acc, T>::type, Ts...> {
39 };
40 
42 
43 namespace detail {
44  struct or_helper {
45  template <class Acc, class T>
46  struct apply : std::integral_constant<bool, Acc::value || T::value> {
47  };
48  };
49 
50  struct and_helper {
51  template <class Acc, class T>
52  struct apply : std::integral_constant<bool, Acc::value && T::value> {
53  };
54 };
55 
56 }//namespace detail
57 
59 
68 
69 template <class... Ts>
70 struct or_ : fold_left <detail::or_helper, std::false_type, Ts...> {
71 };
72 
81 
82 template <class... Ts>
83 struct and_ : fold_left <detail::and_helper, std::true_type, Ts...> {
84 };
85 
86 }//namespace pgs
87 
88 #endif
Parameter pack conjunction.
Definition: logical.hpp:83
Parameter pack disjunction.
Definition: logical.hpp:70
Definition: logical.hpp:13
Fold left, primary template.
Definition: logical.hpp:31