mirror of
https://github.com/catchorg/Catch2.git
synced 2025-06-04 02:47:56 +00:00
Use CATCH_NULL instead of NULL
- expands to nullptr if CATCH_CONFIG_CPP11_NULLPTR is defined (see #444)
This commit is contained in:
parent
3b18d9e962
commit
805de43a3d
25 changed files with 112 additions and 101 deletions
|
@ -16,12 +16,12 @@ namespace Catch {
|
|||
template<typename T>
|
||||
class Option {
|
||||
public:
|
||||
Option() : nullableValue( NULL ) {}
|
||||
Option() : nullableValue( CATCH_NULL ) {}
|
||||
Option( T const& _value )
|
||||
: nullableValue( new( storage ) T( _value ) )
|
||||
{}
|
||||
Option( Option const& _other )
|
||||
: nullableValue( _other ? new( storage ) T( *_other ) : NULL )
|
||||
: nullableValue( _other ? new( storage ) T( *_other ) : CATCH_NULL )
|
||||
{}
|
||||
|
||||
~Option() {
|
||||
|
@ -45,7 +45,7 @@ namespace Catch {
|
|||
void reset() {
|
||||
if( nullableValue )
|
||||
nullableValue->~T();
|
||||
nullableValue = NULL;
|
||||
nullableValue = CATCH_NULL;
|
||||
}
|
||||
|
||||
T& operator*() { return *nullableValue; }
|
||||
|
@ -57,10 +57,10 @@ namespace Catch {
|
|||
return nullableValue ? *nullableValue : defaultValue;
|
||||
}
|
||||
|
||||
bool some() const { return nullableValue != NULL; }
|
||||
bool none() const { return nullableValue == NULL; }
|
||||
bool some() const { return nullableValue != CATCH_NULL; }
|
||||
bool none() const { return nullableValue == CATCH_NULL; }
|
||||
|
||||
bool operator !() const { return nullableValue == NULL; }
|
||||
bool operator !() const { return nullableValue == CATCH_NULL; }
|
||||
operator SafeBool::type() const {
|
||||
return SafeBool::makeSafe( some() );
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue