1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| //==============================================================================
enum ValueTag : uint8_t
{
POS = 0,
SIZE,
SCALE,
TEXTURE
};
//------------------------------------------------------------------------------
enum class TextureTag;
//==============================================================================
template<uint8_t value_tag> struct Value {};
//------------------------------------------------------------------------------
template<> struct Value<POS> { int posx; int posy; };
template<> struct Value<SIZE> { int width; int height; };
template<> struct Value<SCALE> { uint8_t scale; };
template<> struct Value<TEXTURE> { TextureTag texture_tag; };
//==============================================================================
template<uint8_t... TagTail>
struct Entity : public Value<TagTail>...
{};
//==============================================================================
int main()
{
Entity<POS, SCALE, TEXTURE> entity;
entity.posx = 3;
entity.scale = 3;
...
return 0;
}
//============================================================================== |