predicates.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2017-2018 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Namespace
27  Foam::predicates
28 
29 Description
30  Constant predicate types.
31 
32 SourceFiles
33  predicates.H
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef Foam_predicates_H
38 #define Foam_predicates_H
39 
40 #include <string>
41 #include <type_traits>
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 namespace predicates
48 {
49 
50 /*---------------------------------------------------------------------------*\
51  Class always Declaration
52 \*---------------------------------------------------------------------------*/
53 
54 //- Unary and binary predicates that always return true, useful for templating.
55 struct always : std::true_type
56 {
57  //- Unary predicate
58  // \return true
59  template<class T>
60  constexpr bool operator()(const T&) const noexcept
61  {
62  return value;
63  }
64 
65  //- Binary predicate
66  // \return true
67  template<class T1, class T2>
68  constexpr bool operator()(const T1&, const T2&) const noexcept
69  {
70  return value;
71  }
72 
73  //- String match
74  // \return true
75  constexpr bool match(const std::string&, bool literal=false) const noexcept
76  {
77  return value;
78  }
79 };
80 
81 
82 /*---------------------------------------------------------------------------*\
83  Class never Declaration
84 \*---------------------------------------------------------------------------*/
85 
86 //- Unary and binary predicates that never return true, useful for templating.
87 struct never : std::false_type
88 {
89  //- Unary predicate
90  // \return false
91  template<class T>
92  constexpr bool operator()(const T&) const noexcept
93  {
94  return value;
95  }
96 
97  //- Binary predicate
98  // \return false
99  template<class T1, class T2>
100  constexpr bool operator()(const T1&, const T2&) const noexcept
101  {
102  return value;
103  }
105  //- String match
106  // \return false
107  constexpr bool match(const std::string&, bool literal=false) const noexcept
108  {
109  return value;
110  }
111 };
112 
113 
114 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
116 } // End namespace predicates
117 } // End namespace Foam
118 
119 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
120 
121 #endif
122 
123 // ************************************************************************* //
Unary and binary predicates that never return true, useful for templating.
Definition: predicates.H:96
constexpr bool match(const std::string &, bool literal=false) const noexcept
String match.
Definition: predicates.H:82
constexpr bool operator()(const T &) const noexcept
Unary predicate.
Definition: predicates.H:104
constexpr bool operator()(const T &) const noexcept
Unary predicate.
Definition: predicates.H:61
constexpr bool match(const std::string &, bool literal=false) const noexcept
String match.
Definition: predicates.H:125
Unary and binary predicates that always return true, useful for templating.
Definition: predicates.H:53
const direction noexcept
Definition: Scalar.H:258
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Namespace for OpenFOAM.