70. static_assert

Question.6

A template driver validates that the register type is the correct width:

template<typename RegT>
class PeripheralDriver {
   static_assert(sizeof(RegT) == 4,
       "Register type must be 32-bit");
   // ...
};

PeripheralDriver<uint16_t> timer;  // Instantiate with 16-bit type

What happens?

Need Help? Refer to the Quick Guide below

Select Answer