ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkBitwiseOpsFunctors.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * https://www.apache.org/licenses/LICENSE-2.0.txt
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 *=========================================================================*/
18#ifndef itkBitwiseOpsFunctors_h
19#define itkBitwiseOpsFunctors_h
20
21#include "itkMacro.h"
22
23namespace itk::Functor
24{
25
31template <typename TInput1, typename TInput2 = TInput1, typename TOutput = TInput1>
32class ITK_TEMPLATE_EXPORT AND
33{
34public:
35 bool
36 operator==(const AND &) const
37 {
38 return true;
39 }
40
42
43 inline TOutput
44 operator()(const TInput1 & A, const TInput2 & B) const
45 {
46 return static_cast<TOutput>(A & B);
47 }
48};
49
55template <typename TInput1, typename TInput2 = TInput1, typename TOutput = TInput1>
56class ITK_TEMPLATE_EXPORT OR
57{
58public:
59 bool
60 operator==(const OR &) const
61 {
62 return true;
63 }
64
66
67 inline TOutput
68 operator()(const TInput1 & A, const TInput2 & B) const
69 {
70 return static_cast<TOutput>(A | B);
71 }
72};
73
79template <typename TInput1, typename TInput2 = TInput1, typename TOutput = TInput1>
80class ITK_TEMPLATE_EXPORT XOR
81{
82public:
83 bool
84 operator==(const XOR &) const
85 {
86 return true;
87 }
88
90
91 inline TOutput
92 operator()(const TInput1 & A, const TInput2 & B) const
93 {
94 return static_cast<TOutput>(A ^ B);
95 }
96};
97
103template <class TInput, class TOutput>
105{
106public:
107 // Use default copy, assigned and destructor
108 // BitwiseNot() {} default constructor OK
109
110 bool
111 operator==(const BitwiseNot &) const
112 {
113 return true;
114 }
115
117
118 inline TOutput
119 operator()(const TInput & A) const
120 {
121 return static_cast<TOutput>(~A);
122 }
123};
124} // namespace itk::Functor
125
126#endif
bitwise AND functor
TOutput operator()(const TInput1 &A, const TInput2 &B) const
bool operator==(const AND &) const
ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(AND)
Performs the C++ unary bitwise NOT operator.
bool operator==(const BitwiseNot &) const
ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(BitwiseNot)
TOutput operator()(const TInput &A) const
bitwise OR functor
TOutput operator()(const TInput1 &A, const TInput2 &B) const
bool operator==(const OR &) const
ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(OR)
bitwise XOR functor
ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(XOR)
bool operator==(const XOR &) const
TOutput operator()(const TInput1 &A, const TInput2 &B) const