Loading...
Searching...
No Matches
one.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) 2011-2016 OpenFOAM Foundation
9 Copyright (C) 2017-2023 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::one
29
30Description
31 A class representing the concept of 1 (one) that can be used to avoid
32 manipulating objects known to be \em one at compile-time.
33 It is also used for tagged dispatch.
34
35SourceFiles
36 oneI.H
37
38SeeAlso
39 Foam::zero
40
41\*---------------------------------------------------------------------------*/
42
43#ifndef Foam_one_H
44#define Foam_one_H
45
46#include "labelFwd.H"
47
48// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49
50namespace Foam
51{
52
53// Forward Declarations
54class Istream;
55class Ostream;
57/*---------------------------------------------------------------------------*\
58 Class one Declaration
59\*---------------------------------------------------------------------------*/
60
61class one
62{
63public:
64
65 //- The value type
66 typedef one value_type;
67
68 //- Default construct
69 constexpr one() noexcept {}
70
71 //- Construct from Istream consumes no content.
72 explicit constexpr one(Istream&) noexcept {}
74
75 //- Return 1 for label
76 constexpr operator label() const noexcept { return 1; }
77
78 //- Return 1 for float
79 constexpr operator float() const noexcept { return 1; }
80
81 //- Return 1 for double
82 constexpr operator double() const noexcept { return 1; }
83
84 //- Component-wise or element-wise access returns one
85 one operator[](const label) const noexcept { return one{}; }
86};
87
88
89// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
90
91//- Global one (1)
92static constexpr const one One;
93
94// IOstream Operators
95
96//- Read from Istream consumes no content.
97inline constexpr Istream& operator>>(Istream& is, one&) noexcept
98{
99 return is;
100}
101
102
103// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
104
105} // End namespace Foam
106
107// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
108
109// Global Operators, Functions
110#include "oneI.H"
111
112// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
113
114#endif
115
116// ************************************************************************* //
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition Istream.H:60
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
A class representing the concept of 1 (one) that can be used to avoid manipulating objects known to b...
Definition one.H:57
one value_type
The value type.
Definition one.H:63
one operator[](const label) const noexcept
Component-wise or element-wise access returns one.
Definition one.H:94
constexpr one(Istream &) noexcept
Construct from Istream consumes no content.
Definition one.H:73
constexpr one() noexcept
Default construct.
Definition one.H:68
Typedefs for label/uLabel without requiring label.H.
Namespace for OpenFOAM.
Istream & operator>>(Istream &, directionInfo &)
static constexpr const one One
Global one (1).
Definition one.H:103
const direction noexcept
Definition scalarImpl.H:265