Skip to content

Commit c40c3d6

Browse files
committed
signal if wrong type of getJsonValue() in compile-time
1 parent d272993 commit c40c3d6

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

PWGHF/D2H/Macros/runMassFitter.C

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,9 @@ T* getObjectWithNullPtrCheck(TFile* fileIn, const std::string& objectName)
575575
return ptr;
576576
}
577577

578+
template <typename>
579+
constexpr bool AlwaysFalse = false;
580+
578581
template <typename T>
579582
T getJsonValue(const Value& value)
580583
{
@@ -586,9 +589,10 @@ T getJsonValue(const Value& value)
586589
return value.GetInt();
587590
} else if constexpr (std::is_same_v<std::decay_t<T>, double>) {
588591
return value.GetDouble();
592+
} else {
593+
static_assert(AlwaysFalse<T>, "getJsonValue(): unsupported type!");
594+
return T();
589595
}
590-
throw std::runtime_error("getJsonValue(): unsupported type!");
591-
return T();
592596
}
593597

594598
template <typename T>

0 commit comments

Comments
 (0)