aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/util/Cast.hxx13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/util/Cast.hxx b/src/util/Cast.hxx
index c49d18eaa..887137da4 100644
--- a/src/util/Cast.hxx
+++ b/src/util/Cast.hxx
@@ -93,4 +93,17 @@ ContainerCast(A &a, A C::*member)
return *OffsetCast<C, A>(&a, ContainerAttributeOffset<C, A>(member));
}
+/**
+ * Cast the given pointer to a struct member to its parent structure.
+ */
+template<class C, class A>
+#if defined(__clang__) || GCC_CHECK_VERSION(4,7)
+constexpr
+#endif
+static inline const C &
+ContainerCast(const A &a, A C::*member)
+{
+ return *OffsetCast<const C, const A>(&a, ContainerAttributeOffset<C, A>(member));
+}
+
#endif