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 predicates_H
38 #define predicates_H
39 
40 #include <string>
41 #include <type_traits>
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 
48 namespace predicates
49 {
50 
51 /*---------------------------------------------------------------------------*\
52  Class always Declaration
53 \*---------------------------------------------------------------------------*/
54 
55 //- Unary and binary predicates that always return true, useful for templating.
56 struct always : std::true_type
57 {
58  //- Unary predicate
59  // \return true
60  template<class T>
61  constexpr bool operator()(const T&) const noexcept
62  {
63  return value;
64  }
65 
66  //- Binary predicate
67  // \return true
68  template<class T1, class T2>
69  constexpr bool operator()(const T1&, const T2&) const noexcept
70  {
71  return value;
72  }
73 
74  //- String match
75  // \return true
76  constexpr bool match(const std::string&, bool literal=false) const noexcept
77  {
78  return value;
79  }
80 };
81 
82 
83 /*---------------------------------------------------------------------------*\
84  Class never Declaration
85 \*---------------------------------------------------------------------------*/
86 
87 //- Unary and binary predicates that never return true, useful for templating.
88 struct never : std::false_type
89 {
90  //- Unary predicate
91  // \return false
92  template<class T>
93  constexpr bool operator()(const T&) const noexcept
94  {
95  return value;
96  }
97 
98  //- Binary predicate
99  // \return false
100  template<class T1, class T2>
101  constexpr bool operator()(const T1&, const T2&) const noexcept
102  {
103  return value;
104  }
105 
106  //- String match
107  // \return false
108  constexpr bool match(const std::string&, bool literal=false) const noexcept
109  {
110  return value;
111  }
112 };
113 
114 
115 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
116 
117 } // End namespace predicates
118 
119 } // End namespace Foam
120 
121 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
122 
123 #endif
124 
125 // ************************************************************************* //
Foam::predicates::always::match
constexpr bool match(const std::string &, bool literal=false) const noexcept
String match.
Definition: predicates.H:76
Foam::predicates::always::operator()
constexpr bool operator()(const T &) const noexcept
Unary predicate.
Definition: predicates.H:61
Foam::predicates::always
Unary and binary predicates that always return true, useful for templating.
Definition: predicates.H:56
Foam::predicates::always::operator()
constexpr bool operator()(const T1 &, const T2 &) const noexcept
Binary predicate.
Definition: predicates.H:69
Foam::predicates::never::operator()
constexpr bool operator()(const T1 &, const T2 &) const noexcept
Binary predicate.
Definition: predicates.H:101
Foam::T
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Definition: FieldFieldFunctions.C:58
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::predicates::never::operator()
constexpr bool operator()(const T &) const noexcept
Unary predicate.
Definition: predicates.H:93
Foam::predicates::never
Unary and binary predicates that never return true, useful for templating.
Definition: predicates.H:88
Foam::predicates::never::match
constexpr bool match(const std::string &, bool literal=false) const noexcept
String match.
Definition: predicates.H:108