libcyphal
libcyphal copied to clipboard
Require NodeID to always contain a valid value
This is related to type safety; the same principle should be followed wherever applicable.
Objects of NodeID must always contain a valid value of node ID, which is an integer from 0 to 127, inclusive. The validness should be checked in the constructor with an assertion check. There should be no default constructor.
There may exist places where an invalid node ID is required. In that case, std::optional<NodeID> should be used (or a custom replacement if C++17 is not supported).