source: rrlib_util/type_list/tFind.h @ 70:8d36d23fc17e

Last change on this file since 70:8d36d23fc17e was 70:8d36d23fc17e, checked in by Tobias Föhst <foehst@…>, 7 years ago

Reworked type lists

File size: 3.0 KB
Line 
1//
2// You received this file as part of RRLib
3// Robotics Research Library
4//
5// Copyright (C) Finroc GbR (finroc.org)
6//
7// This program is free software; you can redistribute it and/or
8// modify it under the terms of the GNU General Public License
9// as published by the Free Software Foundation; either version 2
10// of the License, or (at your option) any later version.
11//
12// This program is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License
18// along with this program; if not, write to the Free Software
19// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
20//
21//----------------------------------------------------------------------
22/*!\file    tFind.h
23 *
24 * \author  Tobias Foehst
25 *
26 * \date    2011-03-25
27 *
28 * \brief Contains tFind
29 *
30 * \b tFind
31 *
32 */
33//----------------------------------------------------------------------
34#ifndef __rrlib__util__type_list__include_guard__
35#error Invalid include directive. Try #include "rrlib/util/tTypeList.h" instead.
36#endif
37
38#ifndef __rrlib__util__type_lists__tFind_h__
39#define __rrlib__util__type_lists__tFind_h__
40
41//----------------------------------------------------------------------
42// External includes (system with <>, local with "")
43//----------------------------------------------------------------------
44
45//----------------------------------------------------------------------
46// Internal includes with ""
47//----------------------------------------------------------------------
48
49//----------------------------------------------------------------------
50// Debugging
51//----------------------------------------------------------------------
52
53//----------------------------------------------------------------------
54// Namespace declaration
55//----------------------------------------------------------------------
56namespace rrlib
57{
58namespace util
59{
60namespace type_list
61{
62
63//----------------------------------------------------------------------
64// Forward declarations / typedefs / enums
65//----------------------------------------------------------------------
66
67//----------------------------------------------------------------------
68// Class declaration
69//----------------------------------------------------------------------
70//!
71/*!
72 *
73 */
74template <typename TList, typename T>
75class tFind
76{
77  static const size_t cINDEX_IN_TAIL = tFind<typename TList::tTail, T>::cINDEX;
78public:
79  static const size_t cINDEX = cINDEX_IN_TAIL == cNOT_IN_LIST ? cNOT_IN_LIST : cINDEX_IN_TAIL + 1;
80};
81
82template <typename T>
83struct tFind<tEmptyList, T>
84{
85  static const size_t cINDEX = cNOT_IN_LIST;
86};
87
88template <typename TList>
89struct tFind<TList, typename TList::tHead>
90{
91  static const size_t cINDEX = 0;
92};
93
94//----------------------------------------------------------------------
95// End of namespace declaration
96//----------------------------------------------------------------------
97}
98}
99}
100
101#endif
Note: See TracBrowser for help on using the repository browser.