Skip to content

Commit

Permalink
Merge pull request #854 from theodelrieu/fix/force_msvc_stacktrace
Browse files Browse the repository at this point in the history
to/from_json: add a MSVC-specific static_assert to force a stacktrace
  • Loading branch information
nlohmann authored Dec 5, 2017
2 parents f4c0160 + c9a02cb commit 0e3a0b7
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1351,6 +1351,13 @@ struct to_json_fn
{
static_assert(sizeof(BasicJsonType) == 0,
"could not find to_json() method in T's namespace");

#ifdef _MSC_VER
// Visual Studio does not show a stacktrace for the above assert.
using decayed = uncvref_t<T>;
static_assert(sizeof(typename decayed::force_msvc_stacktrace) == 0,
"forcing msvc stacktrace to show which T we're talking about.");
#endif
}

public:
Expand Down Expand Up @@ -1378,6 +1385,12 @@ struct from_json_fn
{
static_assert(sizeof(BasicJsonType) == 0,
"could not find from_json() method in T's namespace");
#ifdef _MSC_VER
// Visual Studio does not show a stacktrace for the above assert.
using decayed = uncvref_t<T>;
static_assert(sizeof(typename decayed::force_msvc_stacktrace) == 0,
"forcing msvc stacktrace to show which T we're talking about.");
#endif
}

public:
Expand Down

0 comments on commit 0e3a0b7

Please sign in to comment.