LOKI library reading - Extended Typelist: Typelist Buyer, MaxSizeof

zhaozj2021-02-16  47

The Typelist _ ** macro in Loki is too difficult to use because unknown parameters cannot be supported.

In view of the idea of ​​tuple in Boost, this Typelist_maker:

template

Struct Typelist_maker {private: TypeList_50 (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T17, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44, T45, T46, T47, T48, T49, T50) TMPLIST; PUBLIC: TYPEDEF TYPENAME ERASEALL :: Result Result;}; this, the world will be clean.

Then a small extension is MaxSizeOf, take a maximum size in a set of types.

The traditional method is to use Union, of course, feel uncomfortable.

Template Struct MaxSizeOf;

Template <> struct maxsizeof {enum {value = 0};

template struct MaxSizeOf > {private: enum {MaxSizeOfTail = MaxSizeOf :: value}; public:? enum {value = (sizeof (Head)> MaxSizeOfTail sizeof ( HEAD): MaxSizeoftail)};

转载请注明原文地址:https://www.9cbs.com/read-26688.html

New Post(0)