2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 * @author Bartosz Janiak (b.janiak@samsung.com)
20 * @brief Generic type list template
22 #ifndef DPL_TYPE_LIST_H
23 #define DPL_TYPE_LIST_H
31 template<size_t Index>
34 struct ERROR_TypeListElementIndexIsOutOfBounds;
35 typedef ERROR_TypeListElementIndexIsOutOfBounds Type;
38 static const size_t Size = 0;
41 template<typename HeadType, typename TailType>
48 template<typename List, size_t Enum>
49 struct TypeCounter : public TypeCounter<typename List::Tail, Enum + 1>
53 struct TypeCounter<TypeListGuard, Enum>
55 static const size_t Size = Enum;
59 typedef TailType Tail;
60 typedef HeadType Head;
61 typedef TypeList<HeadType, TailType> ThisType;
63 template<size_t Index, typename DummyType = DummyClass>
66 typedef typename TailType::template Element<Index - 1>::Type Type;
69 template<typename DummyType>
70 struct Element<0, DummyType>
72 typedef HeadType Type;
75 template<typename Type, typename DummyType = DummyClass>
78 typedef typename TailType::template Contains<Type>::Yes Yes;
81 template<typename DummyType>
82 struct Contains<HeadType, DummyType>
87 static const size_t Size = TypeCounter<ThisType, 0>::Size;
90 template<typename... T>
93 template<typename First, typename... Rest>
94 struct TypeListDecl<First, Rest...>
96 typedef TypeList<First,
97 typename TypeListDecl<Rest...>::Type> Type;
100 template<typename Last>
101 struct TypeListDecl<Last>
103 typedef TypeList<Last, TypeListGuard> Type;
107 struct TypeListDecl<TypeListGuard>
109 typedef TypeListGuard Type;
113 struct TypeListDecl<>
115 typedef TypeListGuard Type;
120 #endif // DPL_TYPE_LIST_H