Skip to content

Commit

Permalink
use always_false to fail static assertions in constexpr if (#737)
Browse files Browse the repository at this point in the history
  • Loading branch information
m-fila authored Feb 18, 2025
1 parent 21d3e4b commit ad6f414
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/rootUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "podio/CollectionIDTable.h"
#include "podio/utilities/RootHelpers.h"
#include "podio/utilities/TypeHelpers.h"

#include "TBranch.h"
#include "TTree.h"
Expand Down Expand Up @@ -58,7 +59,7 @@ consteval auto getGPKeyName() {
} else if constexpr (std::is_same<T, std::string>::value) {
return stringKeyName;
} else {
static_assert(sizeof(T) == 0, "Unsupported type for generic parameters");
static_assert(podio::detail::always_false<T>, "Unsupported type for generic parameters");
}
}

Expand All @@ -76,7 +77,7 @@ consteval auto getGPValueName() {
} else if constexpr (std::is_same<T, std::string>::value) {
return stringValueName;
} else {
static_assert(sizeof(T) == 0, "Unsupported type for generic parameters");
static_assert(podio::detail::always_false<T>, "Unsupported type for generic parameters");
}
}

Expand Down Expand Up @@ -105,7 +106,7 @@ consteval auto getGPBranchOffsets() {
} else if constexpr (std::is_same_v<T, std::string>) {
return GPBranchOffsets{7, 8};
} else {
static_assert(sizeof(T) == 0, "Unsupported type for generic parameters");
static_assert(podio::detail::always_false<T>, "Unsupported type for generic parameters");
}
}

Expand Down

0 comments on commit ad6f414

Please sign in to comment.