digitalmars.D.learn - Mixin a function into a struct only if no member with that name
- Tobias Pankrath (9/9) Dec 29 2021 I am trying to implement the builder pattern for some structs.
- Stanislav Blinov (3/4) Dec 29 2021 Perhaps use opDispatch?
- Tobias Pankrath (3/7) Dec 29 2021 That's a great idea and I'll look into it.
- Adam D Ruppe (3/4) Dec 29 2021 This is the default behavior of template mixins.
I am trying to implement the builder pattern for some structs. Currently I am auto implementing all methods by mixing them into the builder, but now I need some custom logic for some of the fields and I figured I just write them down by hand and mixin the rest. I tried checking if it is contained in the FieldNameTuple, but that (understandably) creates a circular reference: https://run.dlang.io/is/Xih7yP How do I mixin a function only if it is not already present?
Dec 29 2021
On Wednesday, 29 December 2021 at 10:14:13 UTC, Tobias Pankrath wrote:How do I mixin a function only if it is not already present?Perhaps use opDispatch?
Dec 29 2021
On Wednesday, 29 December 2021 at 10:21:07 UTC, Stanislav Blinov wrote:On Wednesday, 29 December 2021 at 10:14:13 UTC, Tobias Pankrath wrote:That's a great idea and I'll look into it.How do I mixin a function only if it is not already present?Perhaps use opDispatch?
Dec 29 2021
On Wednesday, 29 December 2021 at 10:14:13 UTC, Tobias Pankrath wrote:How do I mixin a function only if it is not already present?This is the default behavior of template mixins.
Dec 29 2021