typelist.h
来自「C++封装的视频采集代码」· C头文件 代码 · 共 791 行 · 第 1/3 页
H
791 行
#define TYPELIST_43(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ T11, T12, T13, 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) \ ::Loki::Typelist<T1, TYPELIST_42(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ T11, T12, T13, 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) >#define TYPELIST_44(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ T11, T12, T13, 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) \ ::Loki::Typelist<T1, TYPELIST_43(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ T11, T12, T13, 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) >#define TYPELIST_45(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ T11, T12, T13, 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) \ ::Loki::Typelist<T1, TYPELIST_44(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ T11, T12, T13, 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) >#define TYPELIST_46(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ T11, T12, T13, 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) \ ::Loki::Typelist<T1, TYPELIST_45(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ T11, T12, T13, 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) >#define TYPELIST_47(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ T11, T12, T13, 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) \ ::Loki::Typelist<T1, TYPELIST_46(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ T11, T12, T13, 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) >#define TYPELIST_48(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ T11, T12, T13, 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) \ ::Loki::Typelist<T1, TYPELIST_47(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ T11, T12, T13, 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) >#define TYPELIST_49(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ T11, T12, T13, 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) \ ::Loki::Typelist<T1, TYPELIST_48(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ T11, T12, T13, 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) >#define TYPELIST_50(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ T11, T12, T13, 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) \ ::Loki::Typelist<T1, TYPELIST_49(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ T11, T12, T13, 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) >namespace Loki{////////////////////////////////////////////////////////////////////////////////// class template Typelist// The building block of typelists of any length// Use it through the TYPELIST_NN macros// Defines nested types:// Head (first element, a non-typelist type by convention)// Tail (second element, can be another typelist)//////////////////////////////////////////////////////////////////////////////// template <class T, class U> struct Typelist { typedef T Head; typedef U Tail; }; namespace TL {////////////////////////////////////////////////////////////////////////////////// class template MakeTypelist// Takes a number of arguments equal to its numeric suffix// The arguments are type names.// MakeTypelist<T1, T2, ...>::Result// returns a typelist that is of T1, T2, ...//////////////////////////////////////////////////////////////////////////////// template < typename T1 = NullType, typename T2 = NullType, typename T3 = NullType, typename T4 = NullType, typename T5 = NullType, typename T6 = NullType, typename T7 = NullType, typename T8 = NullType, typename T9 = NullType, typename T10 = NullType, typename T11 = NullType, typename T12 = NullType, typename T13 = NullType, typename T14 = NullType, typename T15 = NullType, typename T16 = NullType, typename T17 = NullType, typename T18 = NullType, typename T19 = NullType, typename T20 = NullType, typename T21 = NullType, typename T22 = NullType, typename T23 = NullType, typename T24 = NullType, typename T25 = NullType, typename T26 = NullType, typename T27 = NullType > struct MakeTypelist { private: typedef typename MakeTypelist < T2 , T3 , T4 , T5 , T6 , T7 , T8 , T9 , T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27 > ::Result TailResult; public: typedef Typelist<T1, TailResult> Result; }; template<> struct MakeTypelist<> { typedef NullType Result; };////////////////////////////////////////////////////////////////////////////////// class template Length// Computes the length of a typelist// Invocation (TList is a typelist):// Length<TList>::value// returns a compile-time constant containing the length of TList, not counting// the end terminator (which by convention is NullType)//////////////////////////////////////////////////////////////////////////////// template <class TList> struct Length; template <class T, class U> struct Length< Typelist<T, U> > { static const int value = 1 + Length<U>::value; }; template <> struct Length<NullType> { static const int value = 0; };////////////////////////////////////////////////////////////////////////////////// class template TypeAt// Finds the type at a given index in a typelist// Invocation (TList is a typelist and index is a compile-time integral// constant):// TypeAt<TList, index>::Result// returns the type in position 'index' in TList// If you pass an out-of-bounds index, the result is a compile-time error//////////////////////////////////////////////////////////////////////////////// template <class TList, int index> struct TypeAt { typedef typename TypeAt<typename TList::Tail, index - 1>::Result Result; }; template <class Head, class Tail> struct TypeAt<Typelist<Head, Tail>, 0> { typedef Head Result; };////////////////////////////////////////////////////////////////////////////////// class template TypeAtNonStrict// Finds the type at a given index in a typelist// Invocations (TList is a typelist and index is a compile-time integral// constant):// a) TypeAt<TList, index>::Result// returns the type in position 'index' in TList, or NullType if index is// out-of-bounds// b) TypeAt<TList, index, D>::Result// returns the type in position 'index' in TList, or D if index is out-of-bounds//////////////////////////////////////////////////////////////////////////////// template<class TList, int index, class DefaultType = NullType> struct TypeAtNonStrict { typedef typename TypeAtNonStrict<typename TList::Tail, index - 1, DefaultType>::Result Result; }; template<class Head, class Tail, class DefaultType> struct TypeAtNonStrict<Typelist<Head, Tail>, 0, DefaultType> { typedef Head Result; }; template<int index, class DefaultType> struct TypeAtNonStrict<NullType, index, DefaultType> { typedef DefaultType Result; };////////////////////////////////////////////////////////////////////////////////// class template IndexOf// Finds the index of a type in a typelist// Invocation (TList is a typelist and T is a type):// IndexOf<TList, T>::value// returns the position of T in TList, or NullType if T is not found in TList//////////////////////////////////////////////////////////////////////////////// template<class TList, class T> struct IndexOf { private: static const int temp = IndexOf<typename TList::Tail, T>::value; public: static const int value = (temp == -1 ? -1 : 1 + temp); }; template <class T, class Tail> struct IndexOf<Typelist<T, Tail>, T> { static const int value = 0; }; template <class T> struct IndexOf<NullType, T> { static const int value = -1; };////////////////////////////////////////////////////////////////////////////////// class template Append// Appends a type or a typelist to another// Invocation (TList is a typelist and T is either a type or a typelist):// Append<TList, T>::Result
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?