From 35cf639fe85a4e6a6595f33b23f4a639bb034fe2 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 24 Jan 2022 10:24:31 +0100 Subject: [PATCH] COMP: noexcept for label/scalar component access - qualify include guards for primitives --- src/OpenFOAM/db/IOstreams/token/token.H | 4 ++-- src/OpenFOAM/primitives/Scalar/Scalar.H | 14 ++++++++------ .../primitives/Scalar/scalar/scalarFwd.H | 4 ++-- src/OpenFOAM/primitives/bools/bool/bool.H | 4 ++-- src/OpenFOAM/primitives/chars/char/char.H | 8 ++++---- src/OpenFOAM/primitives/complex/complex.H | 12 ++++++------ src/OpenFOAM/primitives/ints/int/int.H | 4 ++-- src/OpenFOAM/primitives/ints/int16/int16.H | 4 ++-- src/OpenFOAM/primitives/ints/int32/int32.H | 8 ++++---- src/OpenFOAM/primitives/ints/int64/int64.H | 8 ++++---- src/OpenFOAM/primitives/ints/label/label.H | 17 +++++++++-------- src/OpenFOAM/primitives/ints/label/labelFwd.H | 4 ++-- .../primitives/ints/lists/labelIOList.H | 4 ++-- .../primitives/ints/lists/labelIndList.H | 4 ++-- src/OpenFOAM/primitives/ints/lists/labelList.H | 4 ++-- .../primitives/ints/lists/labelListIOList.H | 4 ++-- src/OpenFOAM/primitives/ints/uLabel/uLabel.H | 17 ++++++++++------- src/OpenFOAM/primitives/ints/uint/uint.H | 4 ++-- src/OpenFOAM/primitives/ints/uint16/uint16.H | 4 ++-- src/OpenFOAM/primitives/ints/uint32/uint32.H | 8 ++++---- src/OpenFOAM/primitives/ints/uint64/uint64.H | 8 ++++---- src/OpenFOAM/primitives/ints/uint8/uint8.H | 12 ++++++------ 22 files changed, 83 insertions(+), 77 deletions(-) diff --git a/src/OpenFOAM/db/IOstreams/token/token.H b/src/OpenFOAM/db/IOstreams/token/token.H index e1ccac5e9f..aea0a49629 100644 --- a/src/OpenFOAM/db/IOstreams/token/token.H +++ b/src/OpenFOAM/db/IOstreams/token/token.H @@ -37,8 +37,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef token_H -#define token_H +#ifndef Foam_token_H +#define Foam_token_H #include "label.H" #include "uLabel.H" diff --git a/src/OpenFOAM/primitives/Scalar/Scalar.H b/src/OpenFOAM/primitives/Scalar/Scalar.H index e526027b36..5295bab847 100644 --- a/src/OpenFOAM/primitives/Scalar/Scalar.H +++ b/src/OpenFOAM/primitives/Scalar/Scalar.H @@ -118,13 +118,13 @@ public: // Member Functions - //- Access to the value + //- Return the value operator Scalar() const noexcept { return p_; } - //- Access to the value + //- Access the value operator Scalar&() noexcept { return p_; @@ -215,15 +215,17 @@ besselFunc2(jn) besselFunc2(yn) -inline Scalar& setComponent(Scalar& s, const direction) +//- Non-const access to scalar-type (has no components) +inline Scalar& setComponent(Scalar& val, const direction) noexcept { - return s; + return val; } -inline Scalar component(const Scalar s, const direction) +//- Return scalar value (has no components) +inline constexpr Scalar component(const Scalar val, const direction) noexcept { - return s; + return val; } diff --git a/src/OpenFOAM/primitives/Scalar/scalar/scalarFwd.H b/src/OpenFOAM/primitives/Scalar/scalar/scalarFwd.H index d692b62391..b34028f7c1 100644 --- a/src/OpenFOAM/primitives/Scalar/scalar/scalarFwd.H +++ b/src/OpenFOAM/primitives/Scalar/scalar/scalarFwd.H @@ -33,8 +33,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef scalarFwd_H -#define scalarFwd_H +#ifndef Foam_scalarFwd_H +#define Foam_scalarFwd_H // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/primitives/bools/bool/bool.H b/src/OpenFOAM/primitives/bools/bool/bool.H index cbd4adc00d..692f87d567 100644 --- a/src/OpenFOAM/primitives/bools/bool/bool.H +++ b/src/OpenFOAM/primitives/bools/bool/bool.H @@ -117,13 +117,13 @@ public: // Member Functions - //- Access to the value + //- Return the value operator bool() const noexcept { return p_; } - //- Access to the value + //- Access the value operator bool&() noexcept { return p_; diff --git a/src/OpenFOAM/primitives/chars/char/char.H b/src/OpenFOAM/primitives/chars/char/char.H index 03cb15ddfb..a1e215de48 100644 --- a/src/OpenFOAM/primitives/chars/char/char.H +++ b/src/OpenFOAM/primitives/chars/char/char.H @@ -35,8 +35,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef char_H -#define char_H +#ifndef Foam_primitives_char_H +#define Foam_primitives_char_H // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -111,13 +111,13 @@ public: // Member Functions - //- Read access to primitive value + //- Return the value operator char() const noexcept { return p_; } - //- Write access to primitive value + //- Access the value operator char&() noexcept { return p_; diff --git a/src/OpenFOAM/primitives/complex/complex.H b/src/OpenFOAM/primitives/complex/complex.H index 815f6419a3..e14b04d1cb 100644 --- a/src/OpenFOAM/primitives/complex/complex.H +++ b/src/OpenFOAM/primitives/complex/complex.H @@ -36,8 +36,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef complex_H -#define complex_H +#ifndef Foam_primitives_complex_H +#define Foam_primitives_complex_H #include "scalar.H" #include "word.H" @@ -307,14 +307,14 @@ public: // Member Functions - //- Access to the value - operator complex() const + //- Return the value + operator complex() const noexcept { return p_; } - //- Access to the value - operator complex&() + //- Access the value + operator complex&() noexcept { return p_; } diff --git a/src/OpenFOAM/primitives/ints/int/int.H b/src/OpenFOAM/primitives/ints/int/int.H index 3157d10a31..906660fd31 100644 --- a/src/OpenFOAM/primitives/ints/int/int.H +++ b/src/OpenFOAM/primitives/ints/int/int.H @@ -34,8 +34,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef int_H -#define int_H +#ifndef Foam_primitives_int_H +#define Foam_primitives_int_H #include "int16.H" #include "int32.H" diff --git a/src/OpenFOAM/primitives/ints/int16/int16.H b/src/OpenFOAM/primitives/ints/int16/int16.H index a0f4341c5a..f7abe5ea16 100644 --- a/src/OpenFOAM/primitives/ints/int16/int16.H +++ b/src/OpenFOAM/primitives/ints/int16/int16.H @@ -34,8 +34,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef int16_H -#define int16_H +#ifndef Foam_primitives_int16_H +#define Foam_primitives_int16_H #include #include "word.H" diff --git a/src/OpenFOAM/primitives/ints/int32/int32.H b/src/OpenFOAM/primitives/ints/int32/int32.H index 6b1e8f9a2a..afdc03cc66 100644 --- a/src/OpenFOAM/primitives/ints/int32/int32.H +++ b/src/OpenFOAM/primitives/ints/int32/int32.H @@ -36,8 +36,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef int32_H -#define int32_H +#ifndef Foam_primitives_int32_H +#define Foam_primitives_int32_H #include #include @@ -183,13 +183,13 @@ public: // Member Functions - //- Access to the value + //- Return the value operator int32_t() const noexcept { return p_; } - //- Access to the value + //- Access the value operator int32_t&() noexcept { return p_; diff --git a/src/OpenFOAM/primitives/ints/int64/int64.H b/src/OpenFOAM/primitives/ints/int64/int64.H index 3d1fdc7c9b..c4cc416912 100644 --- a/src/OpenFOAM/primitives/ints/int64/int64.H +++ b/src/OpenFOAM/primitives/ints/int64/int64.H @@ -36,8 +36,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef int64_H -#define int64_H +#ifndef Foam_primitives_int64_H +#define Foam_primitives_int64_H #include #include @@ -182,13 +182,13 @@ public: // Member Functions - //- Access to the value + //- Return the value operator int64_t() const noexcept { return p_; } - //- Access to the value + //- Access the value operator int64_t&() noexcept { return p_; diff --git a/src/OpenFOAM/primitives/ints/label/label.H b/src/OpenFOAM/primitives/ints/label/label.H index 064de2bf12..a642c07953 100644 --- a/src/OpenFOAM/primitives/ints/label/label.H +++ b/src/OpenFOAM/primitives/ints/label/label.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2014 OpenFOAM Foundation - Copyright (C) 2018-2020 OpenCFD Ltd. + Copyright (C) 2018-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -36,8 +36,8 @@ Description \*---------------------------------------------------------------------------*/ -#ifndef label_H -#define label_H +#ifndef Foam_primitives_label_H +#define Foam_primitives_label_H #include "int.H" #include "labelFwd.H" @@ -119,15 +119,16 @@ label pow(label a, label b); //- Evaluate n! : 0 < n <= 12 label factorial(label n); - -inline label& setComponent(label& l, const direction) +//- Non-const access to integer-type (has no components) +inline label& setComponent(label& val, const direction) noexcept { - return l; + return val; } -inline label component(const label l, const direction) +//- Return integer value (has no components) +inline constexpr label component(const label val, const direction) noexcept { - return l; + return val; } diff --git a/src/OpenFOAM/primitives/ints/label/labelFwd.H b/src/OpenFOAM/primitives/ints/label/labelFwd.H index abe2752896..dbf3357a3c 100644 --- a/src/OpenFOAM/primitives/ints/label/labelFwd.H +++ b/src/OpenFOAM/primitives/ints/label/labelFwd.H @@ -31,8 +31,8 @@ Description \*---------------------------------------------------------------------------*/ -#ifndef labelFwd_H -#define labelFwd_H +#ifndef Foam_primitives_labelFwd_H +#define Foam_primitives_labelFwd_H #include diff --git a/src/OpenFOAM/primitives/ints/lists/labelIOList.H b/src/OpenFOAM/primitives/ints/lists/labelIOList.H index a17ea41b2a..f406ac1ee9 100644 --- a/src/OpenFOAM/primitives/ints/lists/labelIOList.H +++ b/src/OpenFOAM/primitives/ints/lists/labelIOList.H @@ -31,8 +31,8 @@ Description \*---------------------------------------------------------------------------*/ -#ifndef labelIOList_H -#define labelIOList_H +#ifndef Foam_labelIOList_H +#define Foam_labelIOList_H #include "label.H" #include "IOList.H" diff --git a/src/OpenFOAM/primitives/ints/lists/labelIndList.H b/src/OpenFOAM/primitives/ints/lists/labelIndList.H index b6bcb00ee3..56ad93c856 100644 --- a/src/OpenFOAM/primitives/ints/lists/labelIndList.H +++ b/src/OpenFOAM/primitives/ints/lists/labelIndList.H @@ -37,8 +37,8 @@ Description \*---------------------------------------------------------------------------*/ -#ifndef labelIndList_H -#define labelIndList_H +#ifndef Foam_labelIndList_H +#define Foam_labelIndList_H // Include all normal list typedefs as well #include "labelList.H" diff --git a/src/OpenFOAM/primitives/ints/lists/labelList.H b/src/OpenFOAM/primitives/ints/lists/labelList.H index 63276f0fa6..7a38e83969 100644 --- a/src/OpenFOAM/primitives/ints/lists/labelList.H +++ b/src/OpenFOAM/primitives/ints/lists/labelList.H @@ -38,8 +38,8 @@ Description \*---------------------------------------------------------------------------*/ -#ifndef labelList_H -#define labelList_H +#ifndef Foam_labelList_H +#define Foam_labelList_H #include "label.H" #include "List.H" diff --git a/src/OpenFOAM/primitives/ints/lists/labelListIOList.H b/src/OpenFOAM/primitives/ints/lists/labelListIOList.H index 119c1b1b5c..0a9b4868ff 100644 --- a/src/OpenFOAM/primitives/ints/lists/labelListIOList.H +++ b/src/OpenFOAM/primitives/ints/lists/labelListIOList.H @@ -31,8 +31,8 @@ Description \*---------------------------------------------------------------------------*/ -#ifndef labelListIOList_H -#define labelListIOList_H +#ifndef Foam_labelListIOList_H +#define Foam_labelListIOList_H #include "labelList.H" #include "CompactIOList.H" diff --git a/src/OpenFOAM/primitives/ints/uLabel/uLabel.H b/src/OpenFOAM/primitives/ints/uLabel/uLabel.H index 96efd2a2e8..a3f5704e6b 100644 --- a/src/OpenFOAM/primitives/ints/uLabel/uLabel.H +++ b/src/OpenFOAM/primitives/ints/uLabel/uLabel.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2017-2020 OpenCFD Ltd. + Copyright (C) 2017-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -36,8 +36,8 @@ Description \*---------------------------------------------------------------------------*/ -#ifndef uLabel_H -#define uLabel_H +#ifndef Foam_primitives_uLabel_H +#define Foam_primitives_uLabel_H #include "uint.H" #include "labelFwd.H" @@ -109,14 +109,17 @@ uLabel pow(uLabel a, uLabel b); uLabel factorial(uLabel n); -inline uLabel& setComponent(uLabel& l, const direction) +//- Non-const access to unsigned-type (has no components) +inline uLabel& setComponent(uLabel& val, const direction) noexcept { - return l; + return val; } -inline uLabel component(const uLabel l, const direction) + +//- Return unsigned value (has no components) +inline constexpr uLabel component(const uLabel val, const direction) noexcept { - return l; + return val; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/primitives/ints/uint/uint.H b/src/OpenFOAM/primitives/ints/uint/uint.H index bd028df8b6..01e5090771 100644 --- a/src/OpenFOAM/primitives/ints/uint/uint.H +++ b/src/OpenFOAM/primitives/ints/uint/uint.H @@ -35,8 +35,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef uint_H -#define uint_H +#ifndef Foam_primitives_uint_H +#define Foam_primitives_uint_H #include "uint8.H" #include "uint16.H" diff --git a/src/OpenFOAM/primitives/ints/uint16/uint16.H b/src/OpenFOAM/primitives/ints/uint16/uint16.H index 7245c2d40a..7a02b0db15 100644 --- a/src/OpenFOAM/primitives/ints/uint16/uint16.H +++ b/src/OpenFOAM/primitives/ints/uint16/uint16.H @@ -34,8 +34,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef uint16_H -#define uint16_H +#ifndef Foam_primitives_uint16_H +#define Foam_primitives_uint16_H #include #include "word.H" diff --git a/src/OpenFOAM/primitives/ints/uint32/uint32.H b/src/OpenFOAM/primitives/ints/uint32/uint32.H index 5a3f574508..1ca0070823 100644 --- a/src/OpenFOAM/primitives/ints/uint32/uint32.H +++ b/src/OpenFOAM/primitives/ints/uint32/uint32.H @@ -36,8 +36,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef uint32_H -#define uint32_H +#ifndef Foam_primitives_uint32_H +#define Foam_primitives_uint32_H #include #include @@ -169,13 +169,13 @@ public: // Member Functions - //- Access to the value + //- Return the value operator uint32_t() const noexcept { return p_; } - //- Access to the value + //- Access the value operator uint32_t&() noexcept { return p_; diff --git a/src/OpenFOAM/primitives/ints/uint64/uint64.H b/src/OpenFOAM/primitives/ints/uint64/uint64.H index 49dcb96e4a..dd1dae5402 100644 --- a/src/OpenFOAM/primitives/ints/uint64/uint64.H +++ b/src/OpenFOAM/primitives/ints/uint64/uint64.H @@ -36,8 +36,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef uint64_H -#define uint64_H +#ifndef Foam_primitives_uint64_H +#define Foam_primitives_uint64_H #include #include @@ -178,13 +178,13 @@ public: // Member Functions - //- Access to the value + //- Return the value operator uint64_t() const noexcept { return p_; } - //- Access to the value + //- Access the value operator uint64_t&() noexcept { return p_; diff --git a/src/OpenFOAM/primitives/ints/uint8/uint8.H b/src/OpenFOAM/primitives/ints/uint8/uint8.H index a45642adbf..f28ae1a7b9 100644 --- a/src/OpenFOAM/primitives/ints/uint8/uint8.H +++ b/src/OpenFOAM/primitives/ints/uint8/uint8.H @@ -35,8 +35,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef primitives_uint8_H -#define primitives_uint8_H +#ifndef Foam_primitives_uint8_H +#define Foam_primitives_uint8_H #include #include @@ -134,14 +134,14 @@ public: // Member Functions - //- Access to the value - operator uint8_t() const + //- Return the value + operator uint8_t() const noexcept { return p_; } - //- Access to the value - operator uint8_t&() + //- Access the value + operator uint8_t&() noexcept { return p_; }