C++ベースのLightweightなHTTPサーバー
| Revision | 3c4fb39a483a150f8a1b203db8fd5e112d8ef323 (tree) |
|---|---|
| Time | 2013-03-17 13:48:50 |
| Author | Michio Hirai <smg_ykz@user...> |
| Commiter | Michio Hirai |
[Refactor] Addition of mt:Select metafunction
[Refactor] Further refinement of mt::Append metafunction
| @@ -26,6 +26,18 @@ struct StaticValue | ||
| 26 | 26 | static const T value = val; |
| 27 | 27 | }; |
| 28 | 28 | |
| 29 | +template <bool cond, typename Then, typename Else> | |
| 30 | +struct Select | |
| 31 | +{ | |
| 32 | + typedef Else Result; | |
| 33 | +}; | |
| 34 | + | |
| 35 | +template <typename Then, typename Else> | |
| 36 | +struct Select<true, Then, Else> | |
| 37 | +{ | |
| 38 | + typedef Then Result; | |
| 39 | +}; | |
| 40 | + | |
| 29 | 41 | } // namespace mt |
| 30 | 42 | |
| 31 | 43 | #endif // INC_MT_MPL_H_ |
| @@ -17,6 +17,12 @@ struct YesTypeWith1TemplateParam | ||
| 17 | 17 | YesType dummy; |
| 18 | 18 | }; |
| 19 | 19 | |
| 20 | +template <typename T, typename ARG1, typename ARG2> | |
| 21 | +struct YesTypeWith2TemplateParam | |
| 22 | +{ | |
| 23 | + YesType dummy; | |
| 24 | +}; | |
| 25 | + | |
| 20 | 26 | template <typename T, typename R, R (T::*)()> |
| 21 | 27 | struct YesTypeWithNonConstMemberMethodNoArg |
| 22 | 28 | { |
| @@ -39,15 +39,18 @@ struct MakeTypelist<T, NullType> | ||
| 39 | 39 | }; |
| 40 | 40 | |
| 41 | 41 | template <typename TL, typename T> |
| 42 | -struct Append | |
| 42 | +struct Append; | |
| 43 | + | |
| 44 | +template <typename T, typename U, typename V> | |
| 45 | +struct Append<Typelist<T, U>, V> | |
| 43 | 46 | { |
| 44 | - typedef Typelist<typename TL::Head, typename Append<typename TL::Tail, T>::Result > Result; | |
| 47 | + typedef Typelist<T, typename Append<U, V>::Result > Result; | |
| 45 | 48 | }; |
| 46 | 49 | |
| 47 | -template <typename T, typename U> | |
| 48 | -struct Append<Typelist<T, NullType>, U> | |
| 50 | +template <typename T> | |
| 51 | +struct Append<NullType, T> | |
| 49 | 52 | { |
| 50 | - typedef Typelist<T, U> Result; | |
| 53 | + typedef Typelist<T, NullType> Result; | |
| 51 | 54 | }; |
| 52 | 55 | |
| 53 | 56 | template <typename TL, typename T> |