Library: prevent implicit bool conversion on iterator-like objects
...it should have been this way all the time. Generic code might otherwise be ill guided to assume a conversion from the Iterator to its value type, while in fact an explicit dereferentiation is necessary
This commit is contained in:
parent
99e3eeca9f
commit
4988153e15
7 changed files with 63 additions and 17 deletions
|
|
@ -107,6 +107,7 @@ namespace model {
|
|||
and bool{changeState_};
|
||||
}
|
||||
|
||||
explicit
|
||||
operator bool() const
|
||||
{
|
||||
REQUIRE (canExpand());
|
||||
|
|
|
|||
|
|
@ -141,7 +141,11 @@ namespace lib {
|
|||
return *this;
|
||||
}
|
||||
|
||||
operator bool() const { return isValid(); }
|
||||
explicit
|
||||
operator bool() const
|
||||
{
|
||||
return isValid();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -266,7 +270,11 @@ namespace lib {
|
|||
takeAddress();
|
||||
}
|
||||
|
||||
operator bool() const { return isValid(); }
|
||||
explicit
|
||||
operator bool() const
|
||||
{
|
||||
return isValid();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -72,11 +72,15 @@ namespace iter_stl {
|
|||
DistinctIter() : i_(), prev_() { }
|
||||
DistinctIter(IT const& i) : i_(i),prev_() { memorise(); }
|
||||
|
||||
pointer operator->() const { return i_; }
|
||||
reference operator*() const { return *i_;}
|
||||
bool isValid() const { return i_; }
|
||||
pointer operator->() const { return i_; }
|
||||
reference operator*() const { return *i_; }
|
||||
bool isValid() const { return i_; }
|
||||
|
||||
operator bool() const { return i_; }
|
||||
explicit
|
||||
operator bool() const
|
||||
{
|
||||
return bool{i_};
|
||||
}
|
||||
|
||||
|
||||
DistinctIter&
|
||||
|
|
@ -472,8 +476,17 @@ namespace iter_stl {
|
|||
IterSnapshot& operator= (IterSnapshot const&) = default;
|
||||
IterSnapshot& operator= (IterSnapshot &&) = default;
|
||||
|
||||
operator bool() const { return isValid(); }
|
||||
size_t size() const { return buffer_.size(); }
|
||||
explicit
|
||||
operator bool() const
|
||||
{
|
||||
return isValid();
|
||||
}
|
||||
|
||||
size_t
|
||||
size() const
|
||||
{
|
||||
return buffer_.size();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -194,7 +194,11 @@ namespace lib {
|
|||
, pos_()
|
||||
{ }
|
||||
|
||||
operator bool() const { return isValid(); }
|
||||
explicit
|
||||
operator bool() const
|
||||
{
|
||||
return isValid();
|
||||
}
|
||||
|
||||
|
||||
/* === lumiera forward iterator concept === */
|
||||
|
|
@ -352,7 +356,11 @@ namespace lib {
|
|||
: core_()
|
||||
{ }
|
||||
|
||||
operator bool() const { return isValid(); }
|
||||
explicit
|
||||
operator bool() const
|
||||
{
|
||||
return isValid();
|
||||
}
|
||||
|
||||
|
||||
/* === lumiera forward iterator concept === */
|
||||
|
|
@ -491,7 +499,11 @@ namespace lib {
|
|||
, e_(oIter.getEnd())
|
||||
{ }
|
||||
|
||||
operator bool() const { return isValid(); }
|
||||
explicit
|
||||
operator bool() const
|
||||
{
|
||||
return isValid();
|
||||
}
|
||||
|
||||
|
||||
/* === lumiera forward iterator concept === */
|
||||
|
|
@ -599,7 +611,11 @@ namespace lib {
|
|||
|
||||
// standard copy operations acceptable
|
||||
|
||||
operator bool() const { return isValid(); }
|
||||
explicit
|
||||
operator bool() const
|
||||
{
|
||||
return isValid();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -732,7 +748,11 @@ namespace lib {
|
|||
: i_(srcIter)
|
||||
{ }
|
||||
|
||||
operator bool() const { return isValid(); }
|
||||
explicit
|
||||
operator bool() const
|
||||
{
|
||||
return isValid();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -205,7 +205,11 @@ namespace lib {
|
|||
hasData();
|
||||
}
|
||||
|
||||
operator bool() const { return isValid(); }
|
||||
explicit
|
||||
operator bool() const
|
||||
{
|
||||
return isValid();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -257,7 +257,7 @@ namespace lib {
|
|||
return *this;
|
||||
}
|
||||
|
||||
operator bool() { return 0 != tv_sec; } // allows if (timeout_)....
|
||||
explicit operator bool() { return 0 != tv_sec; } // allows if (timeout_)....
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -368,7 +368,7 @@ namespace lib {
|
|||
}
|
||||
|
||||
void setTimeout(ulong relative) {timeout_.setOffset(relative);}
|
||||
bool isTimedWait() {return (timeout_);}
|
||||
bool isTimedWait() {return bool{timeout_};}
|
||||
};
|
||||
|
||||
typedef Mutex<Wrapped_ExclusiveMutex> NonrecursiveLock_NoWait;
|
||||
|
|
|
|||
|
|
@ -1188,7 +1188,7 @@ namespace test{
|
|||
bool
|
||||
checkPoint() const
|
||||
{
|
||||
return src;
|
||||
return bool{src};
|
||||
}
|
||||
|
||||
State&
|
||||
|
|
|
|||
Loading…
Reference in a new issue