aboutsummaryrefslogtreecommitdiff
path: root/include/singleton.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/singleton.hpp')
-rw-r--r--include/singleton.hpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/include/singleton.hpp b/include/singleton.hpp
new file mode 100644
index 0000000..d13e29e
--- /dev/null
+++ b/include/singleton.hpp
@@ -0,0 +1,27 @@
+#ifndef SMOLBOTE_SINGLETON_HPP
+#define SMOLBOTE_SINGLETON_HPP
+
+/*
+ * Clang consumed semantics
+ * States can be: unconsumed, consumed, unknown
+ * Mark classes with consumable(unconsumed)
+ * Mark constructors with return_typestate(unconsumed)
+ * Mark invalidating functions with set_typestate(consumed)
+ */
+
+#if defined(__clang__)
+#define consumable(X) [[clang::consumable(X)]]
+#define return_typestate(X) [[clang::return_typestate(X)]]
+#define set_typestate(X) [[clang::set_typestate(X)]]
+#define callable_when(X) [[clang::callable_when(X)]]
+#define param_typestate(X) [[clang::param_typestate(X)]]
+
+#else
+#define consumable(X)
+#define return_typestate(X)
+#define set_typestate(X)
+#define callable_when(X)
+#define param_typestate(X)
+#endif
+
+#endif // SMOLBOTE_SINGLETON_HPP