diff --git a/src/OpenFOAM/primitives/tuples/Pair.H b/src/OpenFOAM/primitives/tuples/Pair.H index 9548289ac7..48a8538205 100644 --- a/src/OpenFOAM/primitives/tuples/Pair.H +++ b/src/OpenFOAM/primitives/tuples/Pair.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2017-2022 OpenCFD Ltd. + Copyright (C) 2017-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -44,7 +44,8 @@ See also #include "FixedList.H" #include "Istream.H" -#include // For std::move +#include "Ostream.H" +#include // For std::move, std::pair // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -194,6 +195,16 @@ struct is_contiguous_scalar> : is_contiguous_scalar {}; template struct Hash> : Pair::hasher {}; +//- Hashing for std::pair data +template +struct Hash> +{ + unsigned operator()(const std::pair& obj, unsigned seed=0) const + { + return Hash()(obj.second, Hash()(obj.first, seed)); + } +}; + // * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * * // @@ -253,6 +264,32 @@ bool operator>=(const Pair& a, const Pair& b) } +// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // + +//- Read std::pair from Istream +template +inline Istream& operator>>(Istream& is, std::pair& t) +{ + is.readBegin("pair"); + is >> t.first >> t.second; + is.readEnd("pair"); + + is.check(FUNCTION_NAME); + return is; +} + + +//- Write std::pair to Ostream +template +inline Ostream& operator<<(Ostream& os, const std::pair& t) +{ + os << token::BEGIN_LIST + << t.first << token::SPACE << t.second + << token::END_LIST; + return os; +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/OpenFOAM/primitives/tuples/Tuple2.H b/src/OpenFOAM/primitives/tuples/Tuple2.H index 6c6fe3d1ee..ab895b3985 100644 --- a/src/OpenFOAM/primitives/tuples/Tuple2.H +++ b/src/OpenFOAM/primitives/tuples/Tuple2.H @@ -133,17 +133,6 @@ public: // * * * * * * * * * * * * * * * * * Traits * * * * * * * * * * * * * * * * // -//- Hashing for std::pair data -template -struct Hash> -{ - unsigned operator()(const std::pair& obj, unsigned seed=0) const - { - return Hash()(obj.second, Hash()(obj.first, seed)); - } -}; - - //- Hashing for Tuple2 data template struct Hash> @@ -291,19 +280,6 @@ struct maxFirstEqOp // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // -//- Read std::pair from Istream -template -inline Istream& operator>>(Istream& is, std::pair& t) -{ - is.readBegin("pair"); - is >> t.first >> t.second; - is.readEnd("pair"); - - is.check(FUNCTION_NAME); - return is; -} - - //- Read Tuple2 from Istream template inline Istream& operator>>(Istream& is, Tuple2& t) @@ -317,18 +293,7 @@ inline Istream& operator>>(Istream& is, Tuple2& t) } -//- Write std::pair to Ostream. -template -inline Ostream& operator<<(Ostream& os, const std::pair& t) -{ - os << token::BEGIN_LIST - << t.first << token::SPACE << t.second - << token::END_LIST; - return os; -} - - -//- Write Tuple2 to Ostream. +//- Write Tuple2 to Ostream template inline Ostream& operator<<(Ostream& os, const Tuple2& t) {