2 * Copyright (c) 2019 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.
17 #ifndef _NDARRAY_CXX14_H_
18 #define _NDARRAY_CXX14_H_
26 template <size_t... Nums> struct index_sequence
28 using value_type = size_t;
30 static constexpr std::size_t size() noexcept { return sizeof...(Nums); }
36 template <size_t v, typename Seq> struct _append;
38 template <size_t v, size_t... Nums> struct _append<v, index_sequence<Nums...>>
40 using result = index_sequence<Nums..., v>;
43 template <size_t Len> struct make_index_sequence
46 typename detail::_append<Len - 1, typename make_index_sequence<Len - 1>::result>::result;
49 template <> struct make_index_sequence<1>
51 using result = index_sequence<0>;
54 template <> struct make_index_sequence<0>
56 using result = index_sequence<>;
61 template <size_t Num> using make_index_sequence = typename detail::make_index_sequence<Num>::result;
65 } // namespace ndarray
67 #endif //_NDARRAY_CXX14_H_