Skip to content

Commit

Permalink
Enable IsNull() for older versions of MSVC
Browse files Browse the repository at this point in the history
IsNull() is only available for C++11. However, older versions of
MSVC know nullptr and std::nullptr_r and can also handle IsNull().
This commit uses the workaround proposed by @wisk in issue #17 to
enable IsNull() for MSVC version identifiers >= 1600.
  • Loading branch information
sbeyer committed Nov 25, 2016
1 parent 15b6c43 commit 987a882
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion example/basic_assertions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ void BasicAssertions()
"Expected: less than or equal to 5\nActual: 6\n");
}

#if __cplusplus > 199711L
#ifdef SNOWHOUSE_HAS_NULLPTR
std::cout << "ShouldHandleNull" << std::endl;
{
Assert::That(nullptr, IsNull());
Expand Down
2 changes: 1 addition & 1 deletion snowhouse/constraints/equalsconstraint.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ namespace snowhouse {
return EqualsConstraint<bool>(true);
}

#if __cplusplus > 199711L
#ifdef SNOWHOUSE_HAS_NULLPTR
inline EqualsConstraint<std::nullptr_t> IsNull()
{
return EqualsConstraint<std::nullptr_t>(nullptr);
Expand Down
2 changes: 1 addition & 1 deletion snowhouse/fluent/expressionbuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ namespace snowhouse {
return EqualTo<bool>(true);
}

#if __cplusplus > 199711L
#ifdef SNOWHOUSE_HAS_NULLPTR
ExpressionBuilder<typename type_concat<ConstraintListType, ConstraintList<ConstraintAdapter<EqualsConstraint<std::nullptr_t> >, Nil> >::t>
Null()
{
Expand Down
3 changes: 3 additions & 0 deletions snowhouse/snowhouse.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
#endif
#endif

#if __cplusplus > 199711L || (defined(_MSC_VER) && _MSC_VER >= 1600)
# define SNOWHOUSE_HAS_NULLPTR
#endif

#include <iostream>
#include <map>
Expand Down
2 changes: 1 addition & 1 deletion snowhouse/stringize.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ namespace snowhouse {
}
};

#if __cplusplus > 199711L
#ifdef SNOWHOUSE_HAS_NULLPTR
// We need this because nullptr_t has ambiguous overloads of operator<< in the standard library.
template<>
struct Stringizer<std::nullptr_t>
Expand Down

0 comments on commit 987a882

Please sign in to comment.