UFO
1.0.0
An Efficient Probabilistic 3D Mapping Framework That Embraces the Unknown
Loading...
Searching...
No Matches
if_and_only_if.hpp
1
42
#ifndef UFO_CONTAINER_TREE_PREDICATE_IF_AND_ONLY_IF_HPP
43
#define UFO_CONTAINER_TREE_PREDICATE_IF_AND_ONLY_IF_HPP
44
45
// UFO
46
#include <ufo/container/tree/predicate/filter.hpp>
47
#include <ufo/utility/type_traits.hpp>
48
49
// STL
50
#include <type_traits>
51
52
namespace
ufo::pred
53
{
54
template
<Filterable PredLeft, Filterable PredRight>
55
struct
Iff
{
56
Iff
(PredLeft
const
& left, PredRight
const
& right) noexcept : left(left), right(right) {}
57
58
PredLeft left;
59
PredRight right;
60
};
61
62
template
<Filterable PredLeft, Filterable PredRight>
63
struct
Filter
<
Iff
<PredLeft, PredRight>> {
64
using
Pred
=
Iff<PredLeft, PredRight>
;
65
66
template
<
class
Tree>
67
static
constexpr
void
init(
Pred
& p,
Tree
const
& t)
noexcept
68
{
69
Filter<PredLeft>::init
(p.left, t);
70
Filter<PredRight>::init
(p.right, t);
71
}
72
73
template
<
class
Value>
74
[[nodiscard]]
static
constexpr
bool
returnableValue(
Pred
const
& p,
75
Value
const
& v)
noexcept
76
{
77
return
Filter<PredLeft>::returnableValue
(p.left, v) ==
78
Filter<PredRight>::returnableValue
(p.right, v);
79
}
80
81
template
<
class
Tree>
82
[[nodiscard]]
static
constexpr
bool
returnable(
Pred
const
& p,
Tree
const
& t,
83
typename
Tree::Node
const
& n)
noexcept
84
{
85
return
Filter<PredLeft>::returnable
(p.left, t, n) ==
86
Filter<PredRight>::returnable
(p.right, t, n);
87
}
88
89
template
<
class
Tree>
90
[[nodiscard]]
static
constexpr
bool
traversable(
Pred
const
&,
Tree
const
&,
91
typename
Tree::Node
const
&)
noexcept
92
{
93
// NOTE: This is not the same as the returnable check!
94
return
true
;
95
}
96
97
template
<
class
Tree>
98
[[nodiscard]]
static
constexpr
bool
returnableRay(
Pred
const
& p,
Tree
const
& t,
99
typename
Tree::Node
const
& n,
100
typename
Tree::Ray
const
& r)
noexcept
101
{
102
return
Filter<PredLeft>::returnableRay
(p.left, t, n, r) ==
103
Filter<PredRight>::returnableRay
(p.right, t, n, r);
104
}
105
106
template
<
class
Tree>
107
[[nodiscard]]
static
constexpr
bool
traversableRay(
Pred
const
&,
Tree
const
&,
108
typename
Tree::Node
const
&,
109
typename
Tree::Ray
const
&)
noexcept
110
{
111
// NOTE: This is not the same as the returnable check!
112
return
true
;
113
}
114
};
115
116
namespace
detail
117
{
118
template
<Filterable T, Filterable L, Filterable R>
119
struct
contains_pred
<T,
Iff
<L, R>>
120
: std::disjunction<contains_pred<T, L>, contains_pred<T, R>> {
121
};
122
123
template
<Filterable T, Filterable L, Filterable R>
124
struct
contains_always_pred
<T,
Iff
<L, R>> : std::false_type {
125
};
126
}
// namespace detail
127
}
// namespace ufo::pred
128
129
#endif
// UFO_CONTAINER_TREE_PREDICATE_IF_AND_ONLY_IF_HPP
ufo::Tree
Utilizing curiously recurring template pattern (CRTP)
Definition
tree.hpp:104
ufo::pred
Definition
predicate.hpp:74
ufo::Ray< Dim, coord_type >
ufo::TreeNode
Definition
node.hpp:57
ufo::pred::Filter
Definition
filter.hpp:51
ufo::pred::Iff
Definition
if_and_only_if.hpp:55
ufo::pred::detail::contains_always_pred
Definition
filter.hpp:70
ufo::pred::detail::contains_pred
Definition
filter.hpp:62
lib
container
include
ufo
container
tree
predicate
if_and_only_if.hpp
Generated by
1.9.8