OSVR-Core
FindFirst.h
Go to the documentation of this file.
1 
11 // Copyright 2015 Sensics, Inc.
12 // TypePack is part of OSVR-Core.
13 //
14 // Use, modification and distribution is subject to the
15 // Boost Software License, Version 1.0. (See accompanying
16 // file LICENSE_1_0.txt or copy at
17 // http://www.boost.org/LICENSE_1_0.txt)
18 
19 #ifndef INCLUDED_FindFirst_h_GUID_FA5855C9_2243_4DA5_B9B7_ED766E8348FE
20 #define INCLUDED_FindFirst_h_GUID_FA5855C9_2243_4DA5_B9B7_ED766E8348FE
21 
22 // Internal Includes
23 #include "T.h"
24 #include "SizeT.h"
25 #include "List.h"
26 
27 // Library/third-party includes
28 // - none
29 
30 // Standard includes
31 // - none
32 
33 namespace osvr {
34 namespace typepack {
35  namespace detail {
36  template <typename Needle, std::size_t i, typename... Ts>
38  // Expand lists
39  template <typename Needle, typename... Ts>
40  struct find_first_impl<Needle, 0, list<Ts...>>
41  : find_first_impl<Needle, 0, Ts...> {};
42  // base case: at the head
43  template <typename Needle, std::size_t i, typename... Ts>
44  struct find_first_impl<Needle, i, Needle, Ts...> {
45  using type = size_t_<i>;
46  };
47  // Recursive case
48  template <typename Needle, std::size_t i, typename Head, typename... Ts>
49  struct find_first_impl<Needle, i, Head, Ts...> {
50  using type = t_<find_first_impl<Needle, i + 1, Ts...>>;
51  };
53  template <typename Needle, std::size_t i>
54  struct find_first_impl<Needle, i> {};
55 
56  } // namespace detail
57 
60  template <typename List, typename Needle>
62 
63 } // namespace typepack
64 } // namespace osvr
65 
66 #endif // INCLUDED_FindFirst_h_GUID_FA5855C9_2243_4DA5_B9B7_ED766E8348FE
The main namespace for all C++ elements of the framework, internal and external.
Definition: namespace_osvr.dox:3
Header.
A wrapper for a template parameter pack of types.
Definition: List.h:52
Definition: FindFirst.h:37
Definition: newuoa.h:1888
Header.
Header.
t_< detail::find_first_impl< Needle, 0, List >> find_first
Returns the zero-based index of the first instance of Needle in List.
Definition: FindFirst.h:61
typename T::type t_
A convenience alias template to extract the nested type within the supplied T.
Definition: T.h:52
std::integral_constant< std::size_t, V > size_t_
Alias template to simplify creating an integral constant of size_t.
Definition: SizeT.h:46