Avoid issues in run-time by asserting that object created once in compile time and avoid dynamic objects
Lets assume there are number of HW resources which can't be used by two modules of an app. Let say Pins. There are different hardware configurations and different builds are done - it would be great to make sure one HW resource (like a pin in simplest case) is used only once and not checking this in runtime.
template <uint8_t pin>
struct Pin {
static constexpr uint8_t Number = pin;
/*.... */
}
Then i can create
Pin<1> pin1;
Pin<2> pin2;
I wonder if I can get compilation error/assert when I declare same pin one more time:
Pin<2> pin2duplicate;