Commit 4933d789 authored by Guillaume Roguez's avatar Guillaume Roguez Committed by Edric Milaret

mark all bool operator as explicit

This patch prevents unattended behaviour of == and != operator
on instance of classes that user-overload bool operator.
This is done by add explicit keyword to bool operator and
explicitly define == and != operators where needed.

Change-Id: Ic5c5d62c7b0231619539f0d046413ea8129ff515
Tuleap: #674
parent 17d8bd0b
......@@ -237,7 +237,7 @@ public:
return mkiLength_;
}
operator bool() const {
inline explicit operator bool() const {
return not tag_.empty();
}
......
......@@ -104,7 +104,7 @@ class SdesNegotiator {
ring::CryptoAttribute
negotiate(const std::vector<std::string>& attributes) const;
operator bool() const {
inline explicit operator bool() const {
return not localCapabilities_.empty();
}
......
......@@ -46,7 +46,7 @@ Mapping& Mapping::operator=(Mapping&& other)
return *this;
}
bool operator== (Mapping &cMap1, Mapping &cMap2)
bool operator== (const Mapping& cMap1, const Mapping& cMap2)
{
/* we don't compare the description because it doesn't change the function of the
* mapping; we don't compare the IGD because for now we assume that we always
......@@ -57,7 +57,7 @@ bool operator== (Mapping &cMap1, Mapping &cMap2)
cMap1.type_ == cMap2.type_);
}
bool operator!= (Mapping &cMap1, Mapping &cMap2)
bool operator!= (const Mapping& cMap1, const Mapping& cMap2)
{
return !(cMap1 == cMap2);
}
......
......@@ -60,8 +60,8 @@ public:
~Mapping() = default;
friend bool operator== (Mapping &cRedir1, Mapping &cRedir2);
friend bool operator!= (Mapping &cRedir1, Mapping &cRedir2);
friend bool operator== (const Mapping& cRedir1, const Mapping& cRedir2);
friend bool operator!= (const Mapping& cRedir1, const Mapping& cRedir2);
uint16_t getPortExternal() const { return port_external_; };
std::string getPortExternalStr() const { return ring::to_string(port_external_); };
......@@ -79,7 +79,7 @@ public:
return port_external_ == 0 or port_internal_ == 0 ? false : true;
};
inline operator bool() const {
inline explicit operator bool() const {
return isValid();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment