From a182a6c9daeeb44cb78614590cf10db546b1f6a7 Mon Sep 17 00:00:00 2001 From: Oliver Sander <oliver.sander@tu-dresden.de> Date: Sun, 10 Mar 2024 16:15:38 +0100 Subject: [PATCH] Implement std::tuple_element and std::tuple_size for ProductManifold --- CHANGELOG.md | 3 +++ dune/gfe/spaces/productmanifold.hh | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b51284fef..a5a86d957 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,9 @@ - The `RigidBodyMotion` class has been removed. Please use `ProductManifold<RealTuple,Rotation>` from now on. +- You can use `std::tuple_element` and `std::tuple_size` with + `ProductManifold`s now. + - Building the module requires CMake version 3.16 now, to be in line with the current core modules. diff --git a/dune/gfe/spaces/productmanifold.hh b/dune/gfe/spaces/productmanifold.hh index 78a7ffe0e..5bb4ef910 100644 --- a/dune/gfe/spaces/productmanifold.hh +++ b/dune/gfe/spaces/productmanifold.hh @@ -485,4 +485,27 @@ namespace Dune::GFE std::tuple<TargetSpaces ...> data_; }; } + +namespace std +{ + /** \brief Make std::tuple_element work for ProductManifold + * + * As a container it is essentially a std::tuple after all. + */ + template <size_t i, typename ... Args> + struct tuple_element<i,Dune::GFE::ProductManifold<Args...> > + { + using type = typename std::tuple_element<i, std::tuple<Args...> >::type; + }; + + /** \brief Make std::tuple_size work for ProductManifold + * + * As a container it is essentially a std::tuple after all. + */ + template <typename ... Args> + struct tuple_size<Dune::GFE::ProductManifold<Args...> > + : std::integral_constant<std::size_t, sizeof...(Args)> + {}; +} + #endif -- GitLab