COMP: noexcept for label/scalar component access

- qualify include guards for primitives
This commit is contained in:
Mark Olesen
2022-01-24 10:24:31 +01:00
parent c3703226c1
commit 35cf639fe8
22 changed files with 83 additions and 77 deletions

View File

@ -37,8 +37,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef token_H #ifndef Foam_token_H
#define token_H #define Foam_token_H
#include "label.H" #include "label.H"
#include "uLabel.H" #include "uLabel.H"

View File

@ -118,13 +118,13 @@ public:
// Member Functions // Member Functions
//- Access to the value //- Return the value
operator Scalar() const noexcept operator Scalar() const noexcept
{ {
return p_; return p_;
} }
//- Access to the value //- Access the value
operator Scalar&() noexcept operator Scalar&() noexcept
{ {
return p_; return p_;
@ -215,15 +215,17 @@ besselFunc2(jn)
besselFunc2(yn) 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;
} }

View File

@ -33,8 +33,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef scalarFwd_H #ifndef Foam_scalarFwd_H
#define scalarFwd_H #define Foam_scalarFwd_H
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -117,13 +117,13 @@ public:
// Member Functions // Member Functions
//- Access to the value //- Return the value
operator bool() const noexcept operator bool() const noexcept
{ {
return p_; return p_;
} }
//- Access to the value //- Access the value
operator bool&() noexcept operator bool&() noexcept
{ {
return p_; return p_;

View File

@ -35,8 +35,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef char_H #ifndef Foam_primitives_char_H
#define char_H #define Foam_primitives_char_H
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -111,13 +111,13 @@ public:
// Member Functions // Member Functions
//- Read access to primitive value //- Return the value
operator char() const noexcept operator char() const noexcept
{ {
return p_; return p_;
} }
//- Write access to primitive value //- Access the value
operator char&() noexcept operator char&() noexcept
{ {
return p_; return p_;

View File

@ -36,8 +36,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef complex_H #ifndef Foam_primitives_complex_H
#define complex_H #define Foam_primitives_complex_H
#include "scalar.H" #include "scalar.H"
#include "word.H" #include "word.H"
@ -307,14 +307,14 @@ public:
// Member Functions // Member Functions
//- Access to the value //- Return the value
operator complex() const operator complex() const noexcept
{ {
return p_; return p_;
} }
//- Access to the value //- Access the value
operator complex&() operator complex&() noexcept
{ {
return p_; return p_;
} }

View File

@ -34,8 +34,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef int_H #ifndef Foam_primitives_int_H
#define int_H #define Foam_primitives_int_H
#include "int16.H" #include "int16.H"
#include "int32.H" #include "int32.H"

View File

@ -34,8 +34,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef int16_H #ifndef Foam_primitives_int16_H
#define int16_H #define Foam_primitives_int16_H
#include <cstdint> #include <cstdint>
#include "word.H" #include "word.H"

View File

@ -36,8 +36,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef int32_H #ifndef Foam_primitives_int32_H
#define int32_H #define Foam_primitives_int32_H
#include <cstdint> #include <cstdint>
#include <climits> #include <climits>
@ -183,13 +183,13 @@ public:
// Member Functions // Member Functions
//- Access to the value //- Return the value
operator int32_t() const noexcept operator int32_t() const noexcept
{ {
return p_; return p_;
} }
//- Access to the value //- Access the value
operator int32_t&() noexcept operator int32_t&() noexcept
{ {
return p_; return p_;

View File

@ -36,8 +36,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef int64_H #ifndef Foam_primitives_int64_H
#define int64_H #define Foam_primitives_int64_H
#include <cstdint> #include <cstdint>
#include <climits> #include <climits>
@ -182,13 +182,13 @@ public:
// Member Functions // Member Functions
//- Access to the value //- Return the value
operator int64_t() const noexcept operator int64_t() const noexcept
{ {
return p_; return p_;
} }
//- Access to the value //- Access the value
operator int64_t&() noexcept operator int64_t&() noexcept
{ {
return p_; return p_;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2014 OpenFOAM Foundation Copyright (C) 2011-2014 OpenFOAM Foundation
Copyright (C) 2018-2020 OpenCFD Ltd. Copyright (C) 2018-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -36,8 +36,8 @@ Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef label_H #ifndef Foam_primitives_label_H
#define label_H #define Foam_primitives_label_H
#include "int.H" #include "int.H"
#include "labelFwd.H" #include "labelFwd.H"
@ -119,15 +119,16 @@ label pow(label a, label b);
//- Evaluate n! : 0 < n <= 12 //- Evaluate n! : 0 < n <= 12
label factorial(label n); label factorial(label n);
//- Non-const access to integer-type (has no components)
inline label& setComponent(label& l, const direction) 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;
} }

View File

@ -31,8 +31,8 @@ Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef labelFwd_H #ifndef Foam_primitives_labelFwd_H
#define labelFwd_H #define Foam_primitives_labelFwd_H
#include <cstdint> #include <cstdint>

View File

@ -31,8 +31,8 @@ Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef labelIOList_H #ifndef Foam_labelIOList_H
#define labelIOList_H #define Foam_labelIOList_H
#include "label.H" #include "label.H"
#include "IOList.H" #include "IOList.H"

View File

@ -37,8 +37,8 @@ Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef labelIndList_H #ifndef Foam_labelIndList_H
#define labelIndList_H #define Foam_labelIndList_H
// Include all normal list typedefs as well // Include all normal list typedefs as well
#include "labelList.H" #include "labelList.H"

View File

@ -38,8 +38,8 @@ Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef labelList_H #ifndef Foam_labelList_H
#define labelList_H #define Foam_labelList_H
#include "label.H" #include "label.H"
#include "List.H" #include "List.H"

View File

@ -31,8 +31,8 @@ Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef labelListIOList_H #ifndef Foam_labelListIOList_H
#define labelListIOList_H #define Foam_labelListIOList_H
#include "labelList.H" #include "labelList.H"
#include "CompactIOList.H" #include "CompactIOList.H"

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2020 OpenCFD Ltd. Copyright (C) 2017-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -36,8 +36,8 @@ Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef uLabel_H #ifndef Foam_primitives_uLabel_H
#define uLabel_H #define Foam_primitives_uLabel_H
#include "uint.H" #include "uint.H"
#include "labelFwd.H" #include "labelFwd.H"
@ -109,14 +109,17 @@ uLabel pow(uLabel a, uLabel b);
uLabel factorial(uLabel n); 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;
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -35,8 +35,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef uint_H #ifndef Foam_primitives_uint_H
#define uint_H #define Foam_primitives_uint_H
#include "uint8.H" #include "uint8.H"
#include "uint16.H" #include "uint16.H"

View File

@ -34,8 +34,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef uint16_H #ifndef Foam_primitives_uint16_H
#define uint16_H #define Foam_primitives_uint16_H
#include <cstdint> #include <cstdint>
#include "word.H" #include "word.H"

View File

@ -36,8 +36,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef uint32_H #ifndef Foam_primitives_uint32_H
#define uint32_H #define Foam_primitives_uint32_H
#include <cstdint> #include <cstdint>
#include <climits> #include <climits>
@ -169,13 +169,13 @@ public:
// Member Functions // Member Functions
//- Access to the value //- Return the value
operator uint32_t() const noexcept operator uint32_t() const noexcept
{ {
return p_; return p_;
} }
//- Access to the value //- Access the value
operator uint32_t&() noexcept operator uint32_t&() noexcept
{ {
return p_; return p_;

View File

@ -36,8 +36,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef uint64_H #ifndef Foam_primitives_uint64_H
#define uint64_H #define Foam_primitives_uint64_H
#include <cstdint> #include <cstdint>
#include <climits> #include <climits>
@ -178,13 +178,13 @@ public:
// Member Functions // Member Functions
//- Access to the value //- Return the value
operator uint64_t() const noexcept operator uint64_t() const noexcept
{ {
return p_; return p_;
} }
//- Access to the value //- Access the value
operator uint64_t&() noexcept operator uint64_t&() noexcept
{ {
return p_; return p_;

View File

@ -35,8 +35,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef primitives_uint8_H #ifndef Foam_primitives_uint8_H
#define primitives_uint8_H #define Foam_primitives_uint8_H
#include <cstdint> #include <cstdint>
#include <climits> #include <climits>
@ -134,14 +134,14 @@ public:
// Member Functions // Member Functions
//- Access to the value //- Return the value
operator uint8_t() const operator uint8_t() const noexcept
{ {
return p_; return p_;
} }
//- Access to the value //- Access the value
operator uint8_t&() operator uint8_t&() noexcept
{ {
return p_; return p_;
} }