aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-07-14 16:44:17 +0200
committerMax Kellermann <max@duempel.org>2014-07-14 17:08:57 +0200
commitd8558a3af333ee02603a4a07c5bc7031d624f72b (patch)
treeaf5978c6edd777a889b1b0443830e8317f0cce2d /src
parent72eedb1c98a02aac3b08cc58b92018a4cd42d5fc (diff)
downloadmpd-d8558a3af333ee02603a4a07c5bc7031d624f72b.tar.gz
mpd-d8558a3af333ee02603a4a07c5bc7031d624f72b.tar.xz
mpd-d8558a3af333ee02603a4a07c5bc7031d624f72b.zip
util/Cast: add "const" overload
Diffstat (limited to 'src')
-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