Skip to content

Commit c9a02cb

Browse files
committed
to/from_json: add a MSVC-specific static_assert to force a stacktrace
1 parent f4c0160 commit c9a02cb

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

src/json.hpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1351,6 +1351,13 @@ struct to_json_fn
13511351
{
13521352
static_assert(sizeof(BasicJsonType) == 0,
13531353
"could not find to_json() method in T's namespace");
1354+
1355+
#ifdef _MSC_VER
1356+
// Visual Studio does not show a stacktrace for the above assert.
1357+
using decayed = uncvref_t<T>;
1358+
static_assert(sizeof(typename decayed::force_msvc_stacktrace) == 0,
1359+
"forcing msvc stacktrace to show which T we're talking about.");
1360+
#endif
13541361
}
13551362

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

13831396
public:

0 commit comments

Comments
 (0)