type_list.hh

00001 /* vim: set sw=4 sts=4 et foldmethod=syntax : */
00002 
00003 /*
00004  * Copyright (c) 2008, 2009 Ciaran McCreesh
00005  *
00006  * This file is part of the Paludis package manager. Paludis is free software;
00007  * you can redistribute it and/or modify it under the terms of the GNU General
00008  * Public License version 2, as published by the Free Software Foundation.
00009  *
00010  * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
00011  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00012  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
00013  * details.
00014  *
00015  * You should have received a copy of the GNU General Public License along with
00016  * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
00017  * Place, Suite 330, Boston, MA  02111-1307  USA
00018  */
00019 
00020 #ifndef PALUDIS_GUARD_PALUDIS_UTIL_TYPE_LIST_HH
00021 #define PALUDIS_GUARD_PALUDIS_UTIL_TYPE_LIST_HH 1
00022 
00023 #include <paludis/util/type_list-fwd.hh>
00024 
00025 namespace paludis
00026 {
00027     struct TypeListTail
00028     {
00029     };
00030 
00031     template <typename Item_, typename Tail_>
00032     struct TypeListEntry
00033     {
00034         typedef Item_ Item;
00035         typedef Tail_ Tail;
00036     };
00037 
00038 #ifdef PALUDIS_HAVE_VARIADIC_TEMPLATES
00039 
00040     template <>
00041     struct MakeTypeList<>
00042     {
00043         typedef TypeListTail Type;
00044     };
00045 
00046     template <typename H_, typename... T_>
00047     struct MakeTypeList<H_, T_...>
00048     {
00049         typedef TypeListEntry<H_, typename MakeTypeList<T_...>::Type> Type;
00050     };
00051 
00052 #else
00053 
00054     template <typename Item_, typename Tail_>
00055     struct MakeTypeListEntry
00056     {
00057         typedef TypeListEntry<Item_, Tail_> Type;
00058     };
00059 
00060     template <typename Tail_>
00061     struct MakeTypeListEntry<TypeListTail, Tail_>
00062     {
00063         typedef TypeListTail Type;
00064     };
00065 
00066     template <
00067         typename T01_,
00068         typename T02_,
00069         typename T03_,
00070         typename T04_,
00071         typename T05_,
00072         typename T06_,
00073         typename T07_,
00074         typename T08_,
00075         typename T09_,
00076         typename T10_,
00077         typename T11_,
00078         typename T12_,
00079         typename T13_,
00080         typename T14_,
00081         typename T15_,
00082         typename T16_,
00083         typename T17_,
00084         typename T18_,
00085         typename T19_,
00086         typename T20_,
00087         typename T21_,
00088         typename T22_,
00089         typename T23_,
00090         typename T24_,
00091         typename T25_
00092         >
00093     struct MakeTypeList
00094     {
00095         typedef
00096             typename MakeTypeListEntry<T01_,
00097                 typename MakeTypeListEntry<T02_,
00098                     typename MakeTypeListEntry<T03_,
00099                         typename MakeTypeListEntry<T04_,
00100                             typename MakeTypeListEntry<T05_,
00101                                 typename MakeTypeListEntry<T06_,
00102                                     typename MakeTypeListEntry<T07_,
00103                                         typename MakeTypeListEntry<T08_,
00104                                             typename MakeTypeListEntry<T09_,
00105                                                 typename MakeTypeListEntry<T10_,
00106                                                     typename MakeTypeListEntry<T11_,
00107                                                         typename MakeTypeListEntry<T12_,
00108                                                             typename MakeTypeListEntry<T13_,
00109                                                                 typename MakeTypeListEntry<T14_,
00110                                                                     typename MakeTypeListEntry<T15_,
00111                                                                         typename MakeTypeListEntry<T16_,
00112                                                                             typename MakeTypeListEntry<T17_,
00113                                                                                 typename MakeTypeListEntry<T18_,
00114                                                                                     typename MakeTypeListEntry<T19_,
00115                                                                                         typename MakeTypeListEntry<T20_,
00116                                                                                             typename MakeTypeListEntry<T21_,
00117                                                                                                 typename MakeTypeListEntry<T22_,
00118                                                                                                     typename MakeTypeListEntry<T23_,
00119                                                                                                         typename MakeTypeListEntry<T24_,
00120                                                                                                             typename MakeTypeListEntry<T25_, TypeListTail>::Type
00121                                                                                                         >::Type
00122                                                                                                     >::Type
00123                                                                                                 >::Type
00124                                                                                             >::Type
00125                                                                                         >::Type
00126                                                                                     >::Type
00127                                                                                 >::Type
00128                                                                             >::Type
00129                                                                         >::Type
00130                                                                     >::Type
00131                                                                 >::Type
00132                                                             >::Type
00133                                                         >::Type
00134                                                     >::Type
00135                                                 >::Type
00136                                             >::Type
00137                                         >::Type
00138                                     >::Type
00139                                 >::Type
00140                             >::Type
00141                         >::Type
00142                     >::Type
00143                 >::Type
00144             >::Type Type;
00145     };
00146 
00147 #endif
00148 
00149     template <>
00150     struct MakeTypeListConstEntry<TypeListTail>
00151     {
00152         typedef TypeListTail Type;
00153     };
00154 
00155     template <typename Item_, typename Tail_>
00156     struct MakeTypeListConstEntry<TypeListEntry<Item_, Tail_> >
00157     {
00158         typedef TypeListEntry<const Item_, typename MakeTypeListConstEntry<Tail_>::Type> Type;
00159     };
00160 
00161     template <typename TypeList_>
00162     struct MakeTypeListConst
00163     {
00164         typedef typename MakeTypeListConstEntry<TypeList_>::Type Type;
00165     };
00166 
00167     template <typename Item_>
00168     struct TypeListContains<TypeListTail, Item_>
00169     {
00170         enum { value = 0 };
00171     };
00172 
00173     template <typename Item_, typename Tail_>
00174     struct TypeListContains<TypeListEntry<Item_, Tail_>, Item_>
00175     {
00176         enum { value = 1 };
00177     };
00178 
00179     template <typename NotItem_, typename Item_, typename Tail_>
00180     struct TypeListContains<TypeListEntry<NotItem_, Tail_>, Item_>
00181     {
00182         enum { value = TypeListContains<Tail_, Item_>::value };
00183     };
00184 }
00185 
00186 #endif

Generated on Mon Sep 21 10:36:08 2009 for paludis by  doxygen 1.5.4