mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
STYLE: use std::ostringstream instead of std::to_string for complex
- std::to_string(double) is locale sensitive.
This commit is contained in:
@ -44,8 +44,10 @@ Description
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#define CAPITALIZE_bool Bool
|
||||
#define CAPITALIZE_label Label
|
||||
#define CAPITALIZE_scalar Scalar
|
||||
#define CAPITALIZE_complex Complex
|
||||
#define CAPITALIZE_vector Vector
|
||||
#define CAPITALIZE_sphericalTensor SphericalTensor
|
||||
#define CAPITALIZE_symmTensor SymmTensor
|
||||
|
||||
@ -57,6 +57,7 @@ pTraits<Scalar>::pTraits(Istream& is)
|
||||
|
||||
word name(const Scalar val)
|
||||
{
|
||||
// Caution std::to_string(double) is locale sensitive!
|
||||
std::ostringstream buf;
|
||||
buf << val;
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011 OpenFOAM Foundation
|
||||
Copyright (C) 2019 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -28,6 +28,7 @@ License
|
||||
|
||||
#include "complex.H"
|
||||
#include "IOstreams.H"
|
||||
#include <sstream>
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
@ -69,7 +70,11 @@ Foam::complex::complex(Istream& is)
|
||||
|
||||
Foam::word Foam::name(const complex& c)
|
||||
{
|
||||
return '(' + std::to_string(c.Re()) + ',' + std::to_string(c.Im()) + ')';
|
||||
// Caution std::to_string(double) is locale sensitive!
|
||||
std::ostringstream buf;
|
||||
buf << '(' << c.real() << ',' << c.imag() << ')';
|
||||
|
||||
return word(buf.str(), false); // Needs no stripping
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user