summaryrefslogtreecommitdiff
path: root/sigc++/tuple-utils/tuple_start.h
diff options
context:
space:
mode:
authorMurray Cumming <murrayc@murrayc.com>2018-04-15 11:10:45 +0200
committerMurray Cumming <murrayc@murrayc.com>2018-04-15 11:15:23 +0200
commit1759faf552248373714acc573b55421e86cb94cc (patch)
tree8cdb2c9a71514db3682b496bcff9c25ef6103e1f /sigc++/tuple-utils/tuple_start.h
parent12ad173361ce3f8fe2a3cee8c53397891e33abd1 (diff)
downloadsigc++-1759faf552248373714acc573b55421e86cb94cc.tar.gz
C++17: Update from murrayc-tuple-utils.
From https://github.com/murraycu/murrayc-tuple-utils/commits/master This also uses the C++17 nested namespace syntax. Apart from tuple_transform_each, which seems to have a memory access problem, with both g++ and clang++, in its C++17 version.
Diffstat (limited to 'sigc++/tuple-utils/tuple_start.h')
-rw-r--r--sigc++/tuple-utils/tuple_start.h43
1 files changed, 17 insertions, 26 deletions
diff --git a/sigc++/tuple-utils/tuple_start.h b/sigc++/tuple-utils/tuple_start.h
index 06491ce..c220a92 100644
--- a/sigc++/tuple-utils/tuple_start.h
+++ b/sigc++/tuple-utils/tuple_start.h
@@ -21,21 +21,15 @@
#include <tuple>
#include <utility>
-namespace sigc
-{
+namespace sigc::internal {
-namespace internal
-{
-
-namespace detail
-{
+namespace detail {
template <typename T, typename Seq>
struct tuple_type_start_impl;
template <typename T, std::size_t... I>
-struct tuple_type_start_impl<T, std::index_sequence<I...>>
-{
+struct tuple_type_start_impl<T, std::index_sequence<I...>> {
using type = std::tuple<typename std::tuple_element<I, T>::type...>;
};
@@ -45,21 +39,20 @@ struct tuple_type_start_impl<T, std::index_sequence<I...>>
* Get the type of a tuple with just the first @len items.
*/
template <typename T, std::size_t len>
-struct tuple_type_start : detail::tuple_type_start_impl<T, std::make_index_sequence<len>>
-{
-};
+struct tuple_type_start
+ : detail::tuple_type_start_impl<T, std::make_index_sequence<len>> {};
-namespace detail
-{
+namespace detail {
template <typename T, typename Seq>
struct tuple_start_impl;
template <typename T, std::size_t... I>
-struct tuple_start_impl<T, std::index_sequence<I...>>
-{
- static constexpr decltype(auto) tuple_start(T&& t)
- {
+struct tuple_start_impl<T, std::index_sequence<I...>> {
+ static
+ constexpr
+ decltype(auto)
+ tuple_start(T&& t) {
constexpr auto size = std::tuple_size<std::decay_t<T>>::value;
constexpr auto len = sizeof...(I);
static_assert(len <= size, "The tuple size must be less than or equal to the length.");
@@ -75,10 +68,10 @@ struct tuple_start_impl<T, std::index_sequence<I...>>
* Get the tuple with the last @a len items of the original.
*/
template <std::size_t len, typename T>
-constexpr decltype(auto) // typename tuple_type_end<T, len>::type
- tuple_start(T&& t)
-{
- // We use std::decay_t<> because tuple_size is not defined for references.
+constexpr
+decltype(auto) // typename tuple_type_end<T, len>::type
+tuple_start(T&& t) {
+ //We use std::decay_t<> because tuple_size is not defined for references.
constexpr auto size = std::tuple_size<std::decay_t<T>>::value;
static_assert(len <= size, "The tuple size must be less than or equal to the length.");
@@ -86,8 +79,6 @@ constexpr decltype(auto) // typename tuple_type_end<T, len>::type
std::forward<T>(t));
}
-} // namespace internal
-
-} // namespace sigc
+} // namespace sigc::internal;
-#endif // SIGC_TUPLE_UTILS_TUPLE_START_H
+#endif //SIGC_TUPLE_UTILS_TUPLE_START_H