mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 21:36:11 +01:00
Removed SafeBool
This commit is contained in:
parent
e1bca7017d
commit
cc8206f4c3
@ -44,17 +44,6 @@ namespace Catch {
|
|||||||
virtual ~NonCopyable();
|
virtual ~NonCopyable();
|
||||||
};
|
};
|
||||||
|
|
||||||
class SafeBool {
|
|
||||||
public:
|
|
||||||
typedef void (SafeBool::*type)() const;
|
|
||||||
|
|
||||||
static type makeSafe( bool value ) {
|
|
||||||
return value ? &SafeBool::trueValue : 0;
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
void trueValue() const {}
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename ContainerT>
|
template<typename ContainerT>
|
||||||
inline void deleteAll( ContainerT& container ) {
|
inline void deleteAll( ContainerT& container ) {
|
||||||
for( auto p : container )
|
for( auto p : container )
|
||||||
|
@ -61,8 +61,8 @@ namespace Catch {
|
|||||||
bool none() const { return nullableValue == nullptr; }
|
bool none() const { return nullableValue == nullptr; }
|
||||||
|
|
||||||
bool operator !() const { return nullableValue == nullptr; }
|
bool operator !() const { return nullableValue == nullptr; }
|
||||||
operator SafeBool::type() const {
|
explicit operator bool() const {
|
||||||
return SafeBool::makeSafe( some() );
|
return some();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -56,7 +56,7 @@ namespace Catch {
|
|||||||
T& operator*() const { return *m_p; }
|
T& operator*() const { return *m_p; }
|
||||||
T* operator->() const { return m_p; }
|
T* operator->() const { return m_p; }
|
||||||
bool operator !() const { return m_p == nullptr; }
|
bool operator !() const { return m_p == nullptr; }
|
||||||
operator SafeBool::type() const { return SafeBool::makeSafe( m_p != nullptr ); }
|
explicit operator bool() const { return m_p != nullptr; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
T* m_p;
|
T* m_p;
|
||||||
|
@ -293,8 +293,8 @@ struct Boolable
|
|||||||
{
|
{
|
||||||
explicit Boolable( bool value ) : m_value( value ) {}
|
explicit Boolable( bool value ) : m_value( value ) {}
|
||||||
|
|
||||||
operator Catch::SafeBool::type() const {
|
explicit operator bool() const {
|
||||||
return Catch::SafeBool::makeSafe( m_value );
|
return m_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool m_value;
|
bool m_value;
|
||||||
|
Loading…
Reference in New Issue
Block a user