Ginkgo  Generated from tags/v1.0.0^0 branch based on master. Ginkgo version 1.0.0
A numerical linear algebra library targeting many-core architectures
containers.hpp
1 /*******************************<GINKGO LICENSE>******************************
2 Copyright (c) 2017-2019, the Ginkgo authors
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions
7 are met:
8 
9 1. Redistributions of source code must retain the above copyright
10 notice, this list of conditions and the following disclaimer.
11 
12 2. Redistributions in binary form must reproduce the above copyright
13 notice, this list of conditions and the following disclaimer in the
14 documentation and/or other materials provided with the distribution.
15 
16 3. Neither the name of the copyright holder nor the names of its
17 contributors may be used to endorse or promote products derived from
18 this software without specific prior written permission.
19 
20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
21 IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22 TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
23 PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 ******************************<GINKGO LICENSE>*******************************/
32 
33 #ifndef GKO_CORE_SYNTHESIZER_CONTAINERS_
34 #define GKO_CORE_SYNTHESIZER_CONTAINERS_
35 
36 
37 namespace gko {
43 namespace syn {
44 
45 
46 template <typename T, T... Values>
47 struct value_list {};
48 
49 
50 template <typename... Types>
51 struct type_list {};
52 
53 
54 template <int Start, int End, int Step = 1>
55 struct range {};
56 
57 
58 namespace detail {
59 
60 
61 template <typename List1, typename List2>
62 struct concatenate_impl;
63 
64 template <typename T, T... Values1, T... Values2>
65 struct concatenate_impl<value_list<T, Values1...>, value_list<T, Values2...>> {
66  using type = value_list<T, Values1..., Values2...>;
67 };
68 
69 
70 } // namespace detail
71 
72 
73 template <typename List1, typename List2>
74 using concatenate = typename detail::concatenate_impl<List1, List2>::type;
75 
76 
77 namespace detail {
78 
79 
80 template <typename T, typename = void>
81 struct as_list_impl;
82 
83 template <typename T, T... Values>
84 struct as_list_impl<value_list<T, Values...>> {
85  using type = value_list<T, Values...>;
86 };
87 
88 template <typename... Types>
89 struct as_list_impl<type_list<Types...>> {
90  using type = type_list<Types...>;
91 };
92 
93 template <int Start, int End, int Step>
94 struct as_list_impl<range<Start, End, Step>, xstd::enable_if_t<(Start < End)>> {
95  using type = concatenate<
97  typename as_list_impl<range<Start + Step, End, Step>>::type>;
98 };
99 
100 template <int Start, int End, int Step>
101 struct as_list_impl<range<Start, End, Step>,
102  xstd::enable_if_t<(Start >= End)>> {
103  using type = value_list<int>;
104 };
105 
106 
107 } // namespace detail
108 
109 
110 template <typename T>
111 using as_list = typename detail::as_list_impl<T>::type;
112 
113 
114 } // namespace syn
115 } // namespace gko
116 
117 
118 #endif // GKO_CORE_SYNTHESIZER_CONTAINERS_
The Ginkgo namespace.
Definition: abstract_factory.hpp:45
Definition: containers.hpp:51
Definition: containers.hpp:55
Definition: containers.hpp:47