Apache Mesos
cpp14.hpp
Go to the documentation of this file.
1 // Licensed under the Apache License, Version 2.0 (the "License");
2 // you may not use this file except in compliance with the License.
3 // You may obtain a copy of the License at
4 //
5 // http://www.apache.org/licenses/LICENSE-2.0
6 //
7 // Unless required by applicable law or agreed to in writing, software
8 // distributed under the License is distributed on an "AS IS" BASIS,
9 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 // See the License for the specific language governing permissions and
11 // limitations under the License.
12 
13 #ifndef __STOUT_CPP14_HPP__
14 #define __STOUT_CPP14_HPP__
15 
16 #include <cstddef>
17 
18 // This file contains implementation of C++14 standard library features.
19 // Once we adopt C++14, this file should be removed and usages of its
20 // functionality should be replaced with the standard library equivalents
21 // by replacing `cpp14` with `std` and including the appropriate headers.
22 
23 // Note that code in this file may not follow stout conventions strictly
24 // as it uses names as defined in C++ standard.
25 
26 namespace cpp14 {
27 
28 // This is a simplified implementation of C++14 `std::index_sequence`
29 // and `std::make_index_sequence` from <utility>.
30 template <typename T, T... Is>
32 {
33  static constexpr std::size_t size() noexcept { return sizeof...(Is); }
34 };
35 
36 
37 namespace internal {
38 
39 template <typename T, std::size_t N, std::size_t... Is>
40 struct IntegerSequenceGen : IntegerSequenceGen<T, N - 1, N - 1, Is...> {};
41 
42 
43 template <typename T, std::size_t... Is>
44 struct IntegerSequenceGen<T, 0, Is...>
45 {
46  using type = integer_sequence<T, Is...>;
47 };
48 
49 } // namespace internal {
50 
51 
52 template <typename T, std::size_t N>
54 
55 
56 template <std::size_t... Is>
57 using index_sequence = integer_sequence<std::size_t, Is...>;
58 
59 
60 template <std::size_t N>
62 
63 } // namespace cpp14 {
64 
65 #endif // __STOUT_CPP14_HPP__
Definition: cpp14.hpp:31
Definition: cpp14.hpp:40
static constexpr std::size_t size() noexcept
Definition: cpp14.hpp:33
make_integer_sequence< std::size_t, N > make_index_sequence
Definition: cpp14.hpp:61
typename internal::IntegerSequenceGen< T, N >::type make_integer_sequence
Definition: cpp14.hpp:53