You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by mp...@apache.org on 2017/12/01 04:05:29 UTC

mesos git commit: Implemented `std::index_sequence` and related functionality.

Repository: mesos
Updated Branches:
  refs/heads/master 701b24e89 -> ac068c130


Implemented `std::index_sequence` and related functionality.

This adds an implementation of C++14's `std::index_squence` and
`make_index_sequence` templates in <stout/cpp14.hpp>.

Review: https://reviews.apache.org/r/63628/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/ac068c13
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/ac068c13
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/ac068c13

Branch: refs/heads/master
Commit: ac068c130b7c6838324f04aaa84e6f08c0ee1885
Parents: 701b24e
Author: Dmitry Zhuk <dz...@twopensource.com>
Authored: Thu Nov 30 19:08:54 2017 -0800
Committer: Michael Park <mp...@apache.org>
Committed: Thu Nov 30 19:44:43 2017 -0800

----------------------------------------------------------------------
 3rdparty/stout/include/stout/cpp14.hpp | 65 +++++++++++++++++++++++++++++
 1 file changed, 65 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/ac068c13/3rdparty/stout/include/stout/cpp14.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/cpp14.hpp b/3rdparty/stout/include/stout/cpp14.hpp
new file mode 100644
index 0000000..95dfc92
--- /dev/null
+++ b/3rdparty/stout/include/stout/cpp14.hpp
@@ -0,0 +1,65 @@
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//  http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef __STOUT_CPP14_HPP__
+#define __STOUT_CPP14_HPP__
+
+#include <cstddef>
+
+// This file contains implementation of C++14 standard library features.
+// Once we adopt C++14, this file should be removed and usages of its
+// functionality should be replaced with the standard library equivalents
+// by replacing `cpp14` with `std` and including the appropriate headers.
+
+// Note that code in this file may not follow stout conventions strictly
+// as it uses names as defined in C++ standard.
+
+namespace cpp14 {
+
+// This is a simplified implementation of C++14 `std::index_sequence`
+// and `std::make_index_sequence` from <utility>.
+template <typename T, T... Is>
+struct integer_sequence
+{
+  static constexpr std::size_t size() noexcept { return sizeof...(Is); }
+};
+
+
+namespace internal {
+
+template <typename T, std::size_t N, std::size_t... S>
+struct IntegerSequenceGen : IntegerSequenceGen<T, N - 1, N - 1, S...> {};
+
+
+template <typename T, std::size_t... Is>
+struct IntegerSequenceGen<T, 0, Is...>
+{
+  using type = integer_sequence<T, Is...>;
+};
+
+} // namespace internal {
+
+
+template <typename T, std::size_t N>
+using make_integer_sequence = typename internal::IntegerSequenceGen<T, N>::type;
+
+
+template <std::size_t... Is>
+using index_sequence = integer_sequence<std::size_t, Is...>;
+
+
+template <std::size_t N>
+using make_index_sequence = make_integer_sequence<std::size_t, N>;
+
+} // namespace cpp14 {
+
+#endif // __STOUT_CPP14_HPP__