UFO 1.0.0
An Efficient Probabilistic 3D Mapping Framework That Embraces the Unknown
Loading...
Searching...
No Matches
bool.hpp
1
42#ifndef UFO_CONTAINER_TREE_PREDICATE_BOOL_HPP
43#define UFO_CONTAINER_TREE_PREDICATE_BOOL_HPP
44
45// UFO
46#include <ufo/container/tree/predicate/filter.hpp>
47#include <ufo/utility/type_traits.hpp>
48
49namespace ufo::pred
50{
51struct Bool {
52 bool value{};
53
54 constexpr Bool() noexcept = default;
55
56 constexpr explicit Bool(bool value) noexcept : value(value) {}
57};
58
59[[nodiscard]] constexpr Bool operator!(Bool const& p) noexcept { return Bool{!p.value}; }
60
61template <>
62struct Filter<Bool> {
63 using Pred = Bool;
64
65 template <class Tree>
66 static constexpr void init(Pred&, Tree const&) noexcept
67 {
68 }
69
70 template <class Value>
71 [[nodiscard]] static constexpr bool returnableValue(Pred const& p,
72 Value const&) noexcept
73 {
74 return p.value;
75 }
76
77 template <class Tree>
78 [[nodiscard]] static constexpr bool returnable(Pred const& p, Tree const&,
79 typename Tree::Node const&) noexcept
80 {
81 return p.value;
82 }
83
84 template <class Tree>
85 [[nodiscard]] static constexpr bool traversable(Pred const& p, Tree const&,
86 typename Tree::Node const&) noexcept
87 {
88 return p.value;
89 }
90
91 template <class Tree>
92 [[nodiscard]] static constexpr bool returnableRay(Pred const& p, Tree const&,
93 typename Tree::Node const&,
94 typename Tree::Ray const&) noexcept
95 {
96 return p.value;
97 }
98
99 template <class Tree>
100 [[nodiscard]] static constexpr bool traversableRay(Pred const& p, Tree const&,
101 typename Tree::Node const&,
102 typename Tree::Ray const&) noexcept
103 {
104 return p.value;
105 }
106};
107} // namespace ufo::pred
108
109#endif // UFO_CONTAINER_TREE_PREDICATE_BOOL_HPP
Utilizing curiously recurring template pattern (CRTP)
Definition tree.hpp:104