OSVR-Core
Fold.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_Fold_h_GUID_63DEE2B1_33B4_47B3_1289_B30F2B5BEA6B
20 #define INCLUDED_Fold_h_GUID_63DEE2B1_33B4_47B3_1289_B30F2B5BEA6B
21 
22 // Internal Includes
23 #include "SplitList.h"
24 #include "T.h"
25 #include "List.h"
26 #include "Apply.h"
27 
28 // Library/third-party includes
29 // - none
30 
31 // Standard includes
32 // - none
33 
34 namespace osvr {
35 namespace typepack {
36 
37  namespace detail {
38  // Fold: Forward declaration of general form
39  template <typename List, typename State, typename Fun> struct fold_;
40 
41  // Fold: Recurse
42  template <typename List, typename State, typename Fun>
43  struct fold_
44  : fold_<tail<List>, t_<apply<Fun, State, head<List>>>, Fun> {};
45 
46  // Fold: base case
47  template <typename State, typename Fun>
48  struct fold_<list<>, State, Fun> {
49  using type = State;
50  };
51 
52  } // namespace detail
53 
56  template <typename List, typename State, typename Fun>
58 
59 } // namespace typepack
60 } // namespace osvr
61 
62 #endif // INCLUDED_Fold_h_GUID_63DEE2B1_33B4_47B3_1289_B30F2B5BEA6B
Header.
The main namespace for all C++ elements of the framework, internal and external.
Definition: namespace_osvr.dox:3
A wrapper for a template parameter pack of types.
Definition: List.h:52
Definition: Fold.h:39
Definition: newuoa.h:1888
Header.
Header.
Header.
typename T::type t_
A convenience alias template to extract the nested type within the supplied T.
Definition: T.h:52
t_< detail::fold_< List, State, Fun >> fold
Fold the list (right) with the given alias class and initial state.
Definition: Fold.h:57