UniformList.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) 2020 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
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
26Class
27 Foam::UniformList
28
29Description
30 A single value that is represented as a list with an
31 operator[] to access the value.
32 This can be useful for templated operations expecting a list accessor.
33
34Note
35 The list currently has no sizing associated with it.
36
37\*---------------------------------------------------------------------------*/
38
39#ifndef UniformList_H
40#define UniformList_H
41
42#include "labelFwd.H"
43#include <utility>
44
45// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46
47namespace Foam
48{
49
50/*---------------------------------------------------------------------------*\
51 Class UniformList Declaration
52\*---------------------------------------------------------------------------*/
53
54template<class T>
55class UniformList
56{
57 // Private Data
58
59 //- The value to be returned.
60 T value_;
61
62public:
63
64 // Constructors
65
66 //- Construct from given value
67 explicit UniformList(const T& val) noexcept
68 :
69 value_(val)
70 {}
71
72 //- Move construct from given value
73 explicit UniformList(T&& val) noexcept
74 :
75 value_(std::move(val))
76 {}
77
78
79 // Member Functions
80
81 //- Return the value
82 const T& value() const noexcept
83 {
84 return value_;
85 }
86
87 //- Non-const access to the value
89 {
90 return value_;
91 }
92
93
94 // Member Operators
95
96 //- Implicit cast to the value
97 operator const T&() const noexcept
98 {
99 return value_;
100 }
101
102 //- Return the value
103 const T& operator[](const label) const noexcept
104 {
105 return value_;
106 }
107};
108
109
110// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
111
112} // End namespace Foam
113
114#endif
115
116// ************************************************************************* //
A single value that is represented as a list with an operator[] to access the value....
Definition: UniformList.H:55
const T & operator[](const label) const noexcept
Return the value.
Definition: UniformList.H:102
UniformList(const T &val) noexcept
Construct from given value.
Definition: UniformList.H:66
T & value() noexcept
Non-const access to the value.
Definition: UniformList.H:87
UniformList(T &&val) noexcept
Move construct from given value.
Definition: UniformList.H:72
const T & value() const noexcept
Return the value.
Definition: UniformList.H:81
const volScalarField & T
Typedefs for label/uLabel without requiring label.H.
Namespace for OpenFOAM.
const direction noexcept
Definition: Scalar.H:223