summaryrefslogtreecommitdiff
path: root/include/iprt/cpp/utils.h
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2014-03-26 19:21:20 +0000
committer <>2014-05-08 15:03:54 +0000
commitfb123f93f9f5ce42c8e5785d2f8e0edaf951740e (patch)
treec2103d76aec5f1f10892cd1d3a38e24f665ae5db /include/iprt/cpp/utils.h
parent58ed4748338f9466599adfc8a9171280ed99e23f (diff)
downloadVirtualBox-master.tar.gz
Imported from /home/lorry/working-area/delta_VirtualBox/VirtualBox-4.3.10.tar.bz2.HEADVirtualBox-4.3.10master
Diffstat (limited to 'include/iprt/cpp/utils.h')
-rw-r--r--include/iprt/cpp/utils.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/include/iprt/cpp/utils.h b/include/iprt/cpp/utils.h
index e5b269a0..4edc8e5f 100644
--- a/include/iprt/cpp/utils.h
+++ b/include/iprt/cpp/utils.h
@@ -96,6 +96,40 @@ inline C *unconst(const C *that)
return const_cast<C *>(that);
}
+
+/**
+ * Macro for generating a non-const getter version from a const getter.
+ *
+ * @param a_RetType The getter return type.
+ * @param a_Class The class name.
+ * @param a_Getter The getter name.
+ * @param a_ArgDecls The argument declaration for the getter method.
+ * @param a_ArgList The argument list for the call.
+ */
+#define RT_CPP_GETTER_UNCONST(a_RetType, a_Class, a_Getter, a_ArgDecls, a_ArgList) \
+ a_RetType a_Getter a_ArgDecls \
+ { \
+ return static_cast< a_Class const *>(this)-> a_Getter a_ArgList; \
+ }
+
+
+/**
+ * Macro for generating a non-const getter version from a const getter,
+ * unconsting the return value as well.
+ *
+ * @param a_RetType The getter return type.
+ * @param a_Class The class name.
+ * @param a_Getter The getter name.
+ * @param a_ArgDecls The argument declaration for the getter method.
+ * @param a_ArgList The argument list for the call.
+ */
+#define RT_CPP_GETTER_UNCONST_RET(a_RetType, a_Class, a_Getter, a_ArgDecls, a_ArgList) \
+ a_RetType a_Getter a_ArgDecls \
+ { \
+ return const_cast<a_RetType>(static_cast< a_Class const *>(this)-> a_Getter a_ArgList); \
+ }
+
+
/** @} */
#endif