diff options
| author | hachem <im@hachem.wtf> | 2026-09-19 14:49:36 +0200 |
|---|---|---|
| committer | hachem <im@hachem.wtf> | 2026-09-19 14:49:36 +0200 |
| commit | e5cc80fb6a608aa1fbd0d6fabd1cf614a0fc004a (patch) | |
| tree | bf28325d56488de0cfe8cf4634b6307e229ea437 /examples | |
| parent | b79902cd36b2c5b54bbf0f07078fc528754977b2 (diff) | |
fix: add a workaround for redeclaration
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/reassign.sfinae | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/examples/reassign.sfinae b/examples/reassign.sfinae new file mode 100644 index 0000000..9863cae --- /dev/null +++ b/examples/reassign.sfinae @@ -0,0 +1,16 @@ +// there is no assignment. to change x, undeclare it and declare it again +// if the new value depends on the old one, park it in a second variable first, +// because the old one is gone by the time you declare + +::declare<::name<'x'>, ::decltype(::difference<'F', 'A'>)>::commit; +::emit<::decltype(::value_of<::name<'x'>>)>::commit; + +::declare< + ::name<'n', 'e', 'x', 't'>, + ::decltype(::sum<::value_of<::name<'x'>>, ::difference<'B', 'A'>>) +>::commit; +::undeclare<::name<'x'>>::commit; +::declare<::name<'x'>, ::decltype(::value_of<::name<'n', 'e', 'x', 't'>>)>::commit; +::undeclare<::name<'n', 'e', 'x', 't'>>::commit; + +::emit<::decltype(::value_of<::name<'x'>>)>::commit; |
