Add cast-to-bool operators for tree node handles for C++ and D
This commit is contained in:
1 parent
3b914466b3
commit
429ce88eb5
8 files changed
+98
No files matched your search
@@ -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()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user