Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use sizeof(T) == 0 instead of always_false #740

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/podio/detail/Link.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ class LinkT {
!detail::isInterfaceInitializableFrom<FromT, T>) {
setTo(std::move(value));
} else {
static_assert(detail::always_false<T>, "Argument type is ambiguous, can't determine link direction");
static_assert(sizeof(T) == 0, "Argument type is ambiguous, can't determine link direction");
}
}

Expand Down
5 changes: 0 additions & 5 deletions include/podio/utilities/TypeHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ namespace det {

namespace detail {

// A helper variable template that is always false, used for static_asserts
// and other compile-time checks that should always fail.
template <typename T>
inline constexpr bool always_false = false;

/// Helper struct to determine whether a given type T is in a tuple of types
/// that act as a type list in this case
template <typename T, typename>
Expand Down
7 changes: 3 additions & 4 deletions src/rootUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

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

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

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

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

Expand Down
Loading