pass-thru object in assignment of primitive types (strings)
This commit is contained in:
parent
e011328d99
commit
eb3c47c75f
@ -36,16 +36,16 @@ const char* const Foam::instant::typeName = "instant";
|
||||
Foam::instant::instant()
|
||||
{}
|
||||
|
||||
Foam::instant::instant(const scalar tval, const word& tname)
|
||||
Foam::instant::instant(const scalar val, const word& tname)
|
||||
:
|
||||
value_(tval),
|
||||
value_(val),
|
||||
name_(tname)
|
||||
{}
|
||||
|
||||
Foam::instant::instant(const scalar tval)
|
||||
Foam::instant::instant(const scalar val)
|
||||
:
|
||||
value_(tval),
|
||||
name_(Time::timeName(tval))
|
||||
value_(val),
|
||||
name_(Time::timeName(val))
|
||||
{}
|
||||
|
||||
Foam::instant::instant(const word& tname)
|
||||
@ -57,20 +57,19 @@ Foam::instant::instant(const word& tname)
|
||||
|
||||
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
||||
|
||||
int Foam::operator==(const instant& I1, const instant& I2)
|
||||
bool Foam::operator==(const instant& a, const instant& b)
|
||||
{
|
||||
return
|
||||
(
|
||||
I1.value_ < I2.value_ + SMALL
|
||||
&& I1.value_ > I2.value_ - SMALL
|
||||
a.value_ < b.value_ + SMALL
|
||||
&& a.value_ > b.value_ - SMALL
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
int Foam::operator != (const instant& I1, const instant& I2)
|
||||
bool Foam::operator!=(const instant& a, const instant& b)
|
||||
{
|
||||
// Invert the '==' operator ('0'='false')
|
||||
return I1 == I2 ? 0 : 1;
|
||||
return !operator==(a, b);
|
||||
}
|
||||
|
||||
|
||||
|
@ -50,8 +50,8 @@ class instant;
|
||||
|
||||
// Friend Operators
|
||||
|
||||
int operator==(const instant&, const instant&);
|
||||
int operator!=(const instant&, const instant&);
|
||||
bool operator==(const instant&, const instant&);
|
||||
bool operator!=(const instant&, const instant&);
|
||||
|
||||
// IOstream Operators
|
||||
|
||||
@ -79,9 +79,9 @@ public:
|
||||
{
|
||||
public:
|
||||
|
||||
bool operator()(const instant& one, const instant& two) const
|
||||
bool operator()(const instant& a, const instant& b) const
|
||||
{
|
||||
return one.value() < two.value();
|
||||
return a.value() < b.value();
|
||||
}
|
||||
};
|
||||
|
||||
@ -137,8 +137,8 @@ public:
|
||||
|
||||
// Friend Operators
|
||||
|
||||
friend int operator==(const instant&, const instant&);
|
||||
friend int operator!=(const instant&, const instant&);
|
||||
friend bool operator==(const instant&, const instant&);
|
||||
friend bool operator!=(const instant&, const instant&);
|
||||
|
||||
|
||||
// IOstream Operators
|
||||
|
@ -51,13 +51,13 @@ namespace Foam
|
||||
|
||||
class complex;
|
||||
|
||||
inline scalar magSqr(const complex& c);
|
||||
inline complex sqr(const complex& c);
|
||||
inline scalar mag(const complex& c);
|
||||
inline const complex& max(const complex& c1, const complex& c2);
|
||||
inline const complex& min(const complex& c1, const complex& c2);
|
||||
inline complex limit(const complex& c1, const complex& c2);
|
||||
inline const complex& sum(const complex& c);
|
||||
inline scalar magSqr(const complex&);
|
||||
inline complex sqr(const complex&);
|
||||
inline scalar mag(const complex&);
|
||||
inline const complex& max(const complex&, const complex&);
|
||||
inline const complex& min(const complex&, const complex&);
|
||||
inline complex limit(const complex&, const complex&);
|
||||
inline const complex& sum(const complex&);
|
||||
inline complex operator+(const complex&, const complex&);
|
||||
inline complex operator-(const complex&);
|
||||
inline complex operator-(const complex&, const complex&);
|
||||
@ -67,8 +67,8 @@ inline complex operator*(const scalar, const complex&);
|
||||
inline complex operator*(const complex&, const scalar);
|
||||
inline complex operator/(const complex&, const scalar);
|
||||
inline complex operator/(const scalar, const complex&);
|
||||
Istream& operator>>(Istream& is, complex&);
|
||||
Ostream& operator<<(Ostream& os, const complex& C);
|
||||
Istream& operator>>(Istream&, complex&);
|
||||
Ostream& operator<<(Ostream&, const complex&);
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
@ -127,13 +127,13 @@ public:
|
||||
|
||||
// Member operators
|
||||
|
||||
inline void operator=(const complex&);
|
||||
inline const complex& operator=(const complex&);
|
||||
inline void operator+=(const complex&);
|
||||
inline void operator-=(const complex&);
|
||||
inline void operator*=(const complex&);
|
||||
inline void operator/=(const complex&);
|
||||
|
||||
inline void operator=(const scalar);
|
||||
inline const complex& operator=(const scalar);
|
||||
inline void operator+=(const scalar);
|
||||
inline void operator-=(const scalar);
|
||||
inline void operator*=(const scalar);
|
||||
@ -150,12 +150,12 @@ public:
|
||||
friend scalar magSqr(const complex& c);
|
||||
friend complex sqr(const complex& c);
|
||||
friend scalar mag(const complex& c);
|
||||
friend const complex& max(const complex& c1, const complex& c2);
|
||||
friend const complex& min(const complex& c1, const complex& c2);
|
||||
friend const complex& max(const complex&, const complex&);
|
||||
friend const complex& min(const complex&, const complex&);
|
||||
|
||||
friend complex limit(const complex& c1, const complex& c2);
|
||||
friend complex limit(const complex&, const complex&);
|
||||
|
||||
friend const complex& sum(const complex& c);
|
||||
friend const complex& sum(const complex&);
|
||||
|
||||
|
||||
// Friend operators
|
||||
|
@ -76,10 +76,11 @@ inline complex complex::conjugate() const
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
inline void complex::operator=(const complex& c)
|
||||
inline const complex& complex::operator=(const complex& c)
|
||||
{
|
||||
re = c.re;
|
||||
im = c.im;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
@ -109,10 +110,11 @@ inline void complex::operator/=(const complex& c)
|
||||
}
|
||||
|
||||
|
||||
inline void complex::operator=(const scalar s)
|
||||
inline const complex& complex::operator=(const scalar s)
|
||||
{
|
||||
re = s;
|
||||
im = 0.0;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
@ -234,8 +236,8 @@ inline complex operator+(const complex& c1, const complex& c2)
|
||||
{
|
||||
return complex
|
||||
(
|
||||
c1.re+c2.re,
|
||||
c1.im+c2.im
|
||||
c1.re + c2.re,
|
||||
c1.im + c2.im
|
||||
);
|
||||
}
|
||||
|
||||
@ -254,8 +256,8 @@ inline complex operator-(const complex& c1, const complex& c2)
|
||||
{
|
||||
return complex
|
||||
(
|
||||
c1.re-c2.re,
|
||||
c1.im-c2.im
|
||||
c1.re - c2.re,
|
||||
c1.im - c2.im
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -196,36 +196,41 @@ Foam::word Foam::fileName::component
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::fileName::operator=(const fileName& str)
|
||||
const Foam::fileName& Foam::fileName::operator=(const fileName& str)
|
||||
{
|
||||
string::operator=(str);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
void Foam::fileName::operator=(const word& str)
|
||||
const Foam::fileName& Foam::fileName::operator=(const word& str)
|
||||
{
|
||||
string::operator=(str);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
void Foam::fileName::operator=(const string& str)
|
||||
const Foam::fileName& Foam::fileName::operator=(const string& str)
|
||||
{
|
||||
string::operator=(str);
|
||||
stripInvalid();
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
void Foam::fileName::operator=(const std::string& str)
|
||||
const Foam::fileName& Foam::fileName::operator=(const std::string& str)
|
||||
{
|
||||
string::operator=(str);
|
||||
stripInvalid();
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
void Foam::fileName::operator=(const char* str)
|
||||
const Foam::fileName& Foam::fileName::operator=(const char* str)
|
||||
{
|
||||
string::operator=(str);
|
||||
stripInvalid();
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
@ -158,11 +158,11 @@ public:
|
||||
|
||||
// Assignment
|
||||
|
||||
void operator=(const fileName&);
|
||||
void operator=(const word&);
|
||||
void operator=(const string&);
|
||||
void operator=(const std::string&);
|
||||
void operator=(const char*);
|
||||
const fileName& operator=(const fileName&);
|
||||
const fileName& operator=(const word&);
|
||||
const fileName& operator=(const string&);
|
||||
const fileName& operator=(const std::string&);
|
||||
const fileName& operator=(const char*);
|
||||
|
||||
|
||||
// IOstream operators
|
||||
|
@ -106,12 +106,12 @@ public:
|
||||
|
||||
// Assignment
|
||||
|
||||
inline void operator=(const keyType&);
|
||||
inline void operator=(const word&);
|
||||
inline const keyType& operator=(const keyType&);
|
||||
inline const keyType& operator=(const word&);
|
||||
|
||||
//- Assign from regular expression.
|
||||
inline void operator=(const string&);
|
||||
inline void operator=(const char*);
|
||||
inline const keyType& operator=(const string&);
|
||||
inline const keyType& operator=(const char*);
|
||||
|
||||
|
||||
// IOstream operators
|
||||
|
@ -89,34 +89,38 @@ inline bool Foam::keyType::isPattern() const
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
inline void Foam::keyType::operator=(const keyType& s)
|
||||
inline const Foam::keyType& Foam::keyType::operator=(const keyType& s)
|
||||
{
|
||||
// Bypass checking
|
||||
string::operator=(s);
|
||||
isPattern_ = s.isPattern_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline void Foam::keyType::operator=(const word& s)
|
||||
inline const Foam::keyType& Foam::keyType::operator=(const word& s)
|
||||
{
|
||||
word::operator=(s);
|
||||
isPattern_ = false;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline void Foam::keyType::operator=(const string& s)
|
||||
inline const Foam::keyType& Foam::keyType::operator=(const string& s)
|
||||
{
|
||||
// Bypass checking
|
||||
string::operator=(s);
|
||||
isPattern_ = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline void Foam::keyType::operator=(const char* s)
|
||||
inline const Foam::keyType& Foam::keyType::operator=(const char* s)
|
||||
{
|
||||
// Bypass checking
|
||||
string::operator=(s);
|
||||
isPattern_ = false;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
@ -117,10 +117,10 @@ public:
|
||||
|
||||
// Assignment
|
||||
|
||||
inline void operator=(const word&);
|
||||
inline void operator=(const string&);
|
||||
inline void operator=(const std::string&);
|
||||
inline void operator=(const char*);
|
||||
inline const word& operator=(const word&);
|
||||
inline const word& operator=(const string&);
|
||||
inline const word& operator=(const std::string&);
|
||||
inline const word& operator=(const char*);
|
||||
|
||||
|
||||
// Friend Operators
|
||||
|
@ -132,30 +132,34 @@ inline bool Foam::word::valid(char c)
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
inline void Foam::word::operator=(const word& q)
|
||||
inline const Foam::word& Foam::word::operator=(const word& q)
|
||||
{
|
||||
string::operator=(q);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline void Foam::word::operator=(const string& q)
|
||||
inline const Foam::word& Foam::word::operator=(const string& q)
|
||||
{
|
||||
string::operator=(q);
|
||||
stripInvalid();
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline void Foam::word::operator=(const std::string& q)
|
||||
inline const Foam::word& Foam::word::operator=(const std::string& q)
|
||||
{
|
||||
string::operator=(q);
|
||||
stripInvalid();
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline void Foam::word::operator=(const char* q)
|
||||
inline const Foam::word& Foam::word::operator=(const char* q)
|
||||
{
|
||||
string::operator=(q);
|
||||
stripInvalid();
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
@ -187,22 +187,22 @@ public:
|
||||
|
||||
//- Assign copy
|
||||
// Always case sensitive
|
||||
inline void operator=(const wordRe&);
|
||||
inline const wordRe& operator=(const wordRe&);
|
||||
|
||||
//- Copy word, never a regular expression
|
||||
inline void operator=(const word&);
|
||||
inline const wordRe& operator=(const word&);
|
||||
|
||||
//- Copy string, auto-test for regular expression
|
||||
// Always case sensitive
|
||||
inline void operator=(const string&);
|
||||
inline const wordRe& operator=(const string&);
|
||||
|
||||
//- Copy string, auto-test for regular expression
|
||||
// Always case sensitive
|
||||
inline void operator=(const std::string&);
|
||||
inline const wordRe& operator=(const std::string&);
|
||||
|
||||
//- Copy string, auto-test for regular expression
|
||||
// Always case sensitive
|
||||
inline void operator=(const char*);
|
||||
inline const wordRe& operator=(const char*);
|
||||
|
||||
|
||||
// IOstream operators
|
||||
|
@ -213,7 +213,7 @@ inline void Foam::wordRe::set(const char* str, const compOption opt)
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
inline void Foam::wordRe::operator=(const wordRe& str)
|
||||
inline const Foam::wordRe& Foam::wordRe::operator=(const wordRe& str)
|
||||
{
|
||||
string::operator=(str);
|
||||
|
||||
@ -225,34 +225,39 @@ inline void Foam::wordRe::operator=(const wordRe& str)
|
||||
{
|
||||
re_.clear();
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline void Foam::wordRe::operator=(const word& str)
|
||||
inline const Foam::wordRe& Foam::wordRe::operator=(const word& str)
|
||||
{
|
||||
word::operator=(str);
|
||||
re_.clear();
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline void Foam::wordRe::operator=(const string& str)
|
||||
inline const Foam::wordRe& Foam::wordRe::operator=(const string& str)
|
||||
{
|
||||
string::operator=(str);
|
||||
compile(DETECT); // auto-detect regex
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline void Foam::wordRe::operator=(const std::string& str)
|
||||
inline const Foam::wordRe& Foam::wordRe::operator=(const std::string& str)
|
||||
{
|
||||
string::operator=(str);
|
||||
compile(DETECT); // auto-detect regex
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline void Foam::wordRe::operator=(const char* str)
|
||||
inline const Foam::wordRe& Foam::wordRe::operator=(const char* str)
|
||||
{
|
||||
string::operator=(str);
|
||||
compile(DETECT); // auto-detect regex
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user