dwavesystems / dwavesystems/dwave-optimization
Consider using flags to customize `ArrayOutputMixin`
- Dominant language
- C++
- Stars
- 31
- Forks
- 36
- Avg merge
- 16h 55m
- Merged PRs (30d)
- 8
Description
E.g., imagine that you want to disallow an `ArrayNode` from ever being dynamic. It might be nice to be able to specify that as a template argument to `ArrayOutputMixin`. This would allow is to combine different flags like the one we already added to `ScalarOutputMixin` in https://github.com/dwavesystems/dwave-optimization/pull/271.
Something like
```c++
enum class ArrayMixinFlags {
// default is sometimes dynamic
AlwaysDynamic = 1 << 0,
NeverDynamic = 1 << 1,
// default is not to provide a state implementation
ProvideState = 1 << 2,
};
template
class ArrayOutputMixin : public Base {
template
explicit ArrayOutputMixin(Range&& shape)
: ndim_(shape.size()), shape_(make_shape(std::forward(shape))) {
if constexpr (Flags && ArrayMixinFlags::NeverDynamic) {
// throw an error if dynamic
}
}
...
};
class NeverDynamicNode : public ArrayOutputMixin {
...
};
class NeverDynamicAndDefaultStateNode : public ArrayOutputMixin {
...
};
```
Contributor guide
Assessment
This issue has not been assessed yet.