You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add component weights and modernize internals
- Component weight system (Proposal C hybrid): virtual weight() on
component interface (default 1.0), registration-time override via
add(comp, weight), post-registration override via weight(key, value)
- Weight roll in generate_impl; seed always consumed for deterministic
sequence stability regardless of inclusion
- Replace raw const component* with std::reference_wrapper<const component>
- Refactor for loops to std::ranges algorithms (ranges::transform,
ranges::find, ranges::contains, generate_n)
Copy file name to clipboardExpand all lines: README.md
+38-1Lines changed: 38 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,6 +36,8 @@ The library currently supports the following:
36
36
37
37
-**Component Groups**. Define named groups of components for convenient selective generation.
38
38
39
+
-**Component Weights**. Assign inclusion probabilities to components. A weight of `1.0` (default) means always included; `0.5` means included roughly half the time. Weights can be defined in the component interface or overridden per-component at registration time.
40
+
39
41
-**Thread Safety**. Create independent `eg` instances for lock-free concurrent generation.
40
42
41
43
-**Fluent Registration**. Chain `add()` and `remove()` calls to configure the generator.
@@ -341,4 +343,39 @@ for (int i = 0; i < 4; ++i)
341
343
}
342
344
```
343
345
344
-
`eg` is move-constructible and move-assignable, so instances can be transferred between scopes. The `instance()` singleton is still available for single-threaded convenience.
346
+
`eg` is move-constructible and move-assignable, so instances can be transferred between scopes. The `instance()` singleton is still available for single-threaded convenience.
347
+
348
+
### Component Weights
349
+
350
+
Components can declare an inclusion weight via the `weight()` virtual method (default `1.0`). Values range from `0.0` (never included) to `1.0` (always included). The generator rolls against the weight during generation; components that fail the roll are skipped.
**Note:** When a weighted component is skipped, dependent components that call `ctx.get<T>()` for it will throw. Use `ctx.has()` to guard dependency access in weight-sensitive components.
0 commit comments