Add cast-to-bool operators for tree node handles for C++ and D

This commit is contained in:
josh committed 2026-09-05 17:56:18 -04:00
1 parent 3b914466b3
commit 429ce88eb5
8 files changed
+98

No files matched your search

+12
View File
@@ -149,6 +149,12 @@ public struct <%= @grammar.tree_prefix %>Token<%= @grammar.tree_suffix %>
return __id != 0u;
}
/** Support using this handle directly as a boolean condition. */
bool opCast(T : bool)()
{
return __id != 0u;
}
/** Return the node ID (for identity comparison). */
@property <%= @grammar.prefix %>node_id_t node_id()
{
@@ -183,6 +189,12 @@ public struct <%= @grammar.tree_prefix %><%= rule_set.name %><%= @grammar.tree_s
return __id != 0u;
}
/** Support using this handle directly as a boolean condition. */
bool opCast(T : bool)()
{
return __id != 0u;
}
/** Return the node ID (for identity comparison). */
@property <%= @grammar.prefix %>node_id_t node_id()
{