mercredi 16 août 2017

Static array size determined from template values

I'm trying to use static array which size needs to be determined by given template values. However size will be constant across program runtime - thats why I decided not to use std::vector.

template<uint32_t BAR_WIDTH>
class Bar 
{
//do_stuff...
Foo mapper[ [&]()->int{ uint32_t tmp = BAR_WIDTH / Foo:FOO_EDGE; return (BAR_WIDTH % 10 == 0) ? tmp : tmp + 1; }; ];
};

FOO_EGDE is const static value. IDE gives me a hint that

Array size expression must have an integer type instead of int(*)()

I wonder if I can make it work this way without using std::vector. Any advice is welcomed and appreciated.

Aucun commentaire:

Enregistrer un commentaire