samedi 8 août 2020

Using the enum from class template's scope without specyfing template parameters

Having such a code:

template<size_t lines, size_t line_size> class Lcd
{
public:
   enum class Interface : uint8_t
   {
      _8_BIT = 0x30,
      _4_BIT = 0x20,
   };

   Lcd(Interface interface);
   // some other stuff
}
int main()
{
   Lcd<4, 20> lcd(Lcd<4, 20>::Interface::_4_BIT);
}

Could I change the code so that it would be possible to call the Interface enum without using the <4, 20> specifier as the enum is universal?

I would prefer for the enum to be inside the Lcd scope and I need the lines and line_size to be passed through template parameters. Is it fine to just leave it as it is?

Aucun commentaire:

Enregistrer un commentaire