Using C++14, 17 or 20, I am passing two template parameters to a templated class: TSize and MaxSize.
TSize is the type of MaxSize. Obviously, both are known at compile time. TSize needs to be big enough to fit MaxSize.
template <typename TSize = uint8_t, TSize MaxSize = 15>
class Foo {};
How can I automatically deduce TSize by the value of MaxSize, so I have it automatically by just setting the value of MaxSize? i.e.:
if MaxSize<256 -> TSize=uint8_t
if MaxSize<65536 && MaxSize>255 -> TSize=uint16_t
Many thanks for your help!