mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: add explicit flipBoolOp, tighten access on pass-through (noOp) version
- the noOp now returns const reference, noexcept
This commit is contained in:
committed by
Andrew Heather
parent
2d7bad2d2e
commit
cd366b60cc
@ -29,8 +29,7 @@ License
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<>
|
template<> Foam::scalar Foam::flipOp::operator()(const scalar& v) const
|
||||||
Foam::scalar Foam::flipOp::operator()(const scalar& v) const
|
|
||||||
{
|
{
|
||||||
return -v;
|
return -v;
|
||||||
}
|
}
|
||||||
@ -42,7 +41,7 @@ template<> Foam::vector Foam::flipOp::operator()(const vector& v) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<>Foam::sphericalTensor Foam::flipOp::operator()
|
template<> Foam::sphericalTensor Foam::flipOp::operator()
|
||||||
(
|
(
|
||||||
const sphericalTensor& v
|
const sphericalTensor& v
|
||||||
) const
|
) const
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2015-2016 OpenFOAM Foundation
|
Copyright (C) 2015-2016 OpenFOAM Foundation
|
||||||
|
Copyright (C) 2019 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -27,7 +28,7 @@ Class
|
|||||||
Foam::flipOp
|
Foam::flipOp
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Class containing functor to negate primitives. Dummy for all other types.
|
Functor to negate primitives. Dummy for most other types.
|
||||||
|
|
||||||
Used in mesh transformations where face can flip.
|
Used in mesh transformations where face can flip.
|
||||||
|
|
||||||
@ -50,34 +51,40 @@ namespace Foam
|
|||||||
Class flipOp Declaration
|
Class flipOp Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
class flipOp
|
struct flipOp
|
||||||
{
|
{
|
||||||
public:
|
template<class T>
|
||||||
|
T operator()(const T& val) const
|
||||||
template<class Type>
|
|
||||||
Type operator()(const Type& val) const
|
|
||||||
{
|
{
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class noOp
|
//- Pass through value. Should never be specialized.
|
||||||
|
struct noOp
|
||||||
{
|
{
|
||||||
public:
|
template<class T>
|
||||||
|
const T& operator()(const T& val) const noexcept
|
||||||
template<class Type>
|
|
||||||
Type operator()(const Type& val) const
|
|
||||||
{
|
{
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class flipLabelOp
|
//- Invert boolean value
|
||||||
|
struct flipBoolOp
|
||||||
{
|
{
|
||||||
public:
|
bool operator()(const bool& val) const noexcept
|
||||||
|
{
|
||||||
|
return !val;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//- Negate integer values
|
||||||
|
struct flipLabelOp
|
||||||
|
{
|
||||||
label operator()(const label& val) const
|
label operator()(const label& val) const
|
||||||
{
|
{
|
||||||
return -val;
|
return -val;
|
||||||
|
|||||||
Reference in New Issue
Block a user