Skip to content

[llvm] replace static_assert with std::enable_if_t in ilist_node_impl #127722

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

Merged
merged 4 commits into from
Mar 11, 2025
Merged
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
12 changes: 9 additions & 3 deletions llvm/include/llvm/ADT/ilist_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#include "llvm/ADT/ilist_node_base.h"
#include "llvm/ADT/ilist_node_options.h"

#include <type_traits>

namespace llvm {

namespace ilist_detail {
Expand Down Expand Up @@ -147,9 +149,13 @@ class ilist_node_impl
///
/// This requires sentinel tracking to be explicitly enabled. Use the
/// ilist_sentinel_tracking<true> option to get this API.
bool isSentinel() const {
static_assert(OptionsT::is_sentinel_tracking_explicit,
"Use ilist_sentinel_tracking<true> to enable isSentinel()");
///
/// Rather than using static_assert to enforce the API is not called when
/// configured with is_sentinel_tracking_explicit=false, the method is
/// conditionally provided using std::enable_if. This way, clients of
/// ilist_node_impl can be fully instantiated for DLLExport on Windows.
template <typename T = OptionsT>
std::enable_if_t<T::is_sentinel_tracking_explicit, bool> isSentinel() const {
return node_base_type::isSentinel();
}
};
Expand Down