aboutsummaryrefslogtreecommitdiff
path: root/source/lib/include/wanda/meta
diff options
context:
space:
mode:
Diffstat (limited to 'source/lib/include/wanda/meta')
-rw-r--r--source/lib/include/wanda/meta/deferred_failure.hpp21
-rw-r--r--source/lib/include/wanda/meta/keyed.hpp28
-rw-r--r--source/lib/include/wanda/meta/type_wrapper.hpp47
3 files changed, 96 insertions, 0 deletions
diff --git a/source/lib/include/wanda/meta/deferred_failure.hpp b/source/lib/include/wanda/meta/deferred_failure.hpp
new file mode 100644
index 0000000..f74d923
--- /dev/null
+++ b/source/lib/include/wanda/meta/deferred_failure.hpp
@@ -0,0 +1,21 @@
+/**
+ * @file deferred_failure.hpp
+ * @author Felix Morgner (felix.morgner@gmail.com)
+ * @since 1.0.0
+ */
+
+#ifndef WANDA_META_DEFERRED_FAILURE_HPP
+#define WANDA_META_DEFERRED_FAILURE_HPP
+
+#include <type_traits>
+
+namespace wanda::meta
+{
+ /**
+ * @brief A helper type to defer static_assert failures
+ */
+ template<typename...>
+ using deferred_failure = std::false_type;
+} // namespace wanda::meta
+
+#endif \ No newline at end of file
diff --git a/source/lib/include/wanda/meta/keyed.hpp b/source/lib/include/wanda/meta/keyed.hpp
new file mode 100644
index 0000000..a09d1eb
--- /dev/null
+++ b/source/lib/include/wanda/meta/keyed.hpp
@@ -0,0 +1,28 @@
+/**
+ * @file keyed.hpp
+ * @author Felix Morgner (felix.morgner@gmail.com)
+ * @since 1.0.0
+ */
+
+#ifndef WANDA_META_KEYED_HPP
+#define WANDA_META_KEYED_HPP
+
+namespace wanda::meta
+{
+ /**
+ * @brief A tag type to prevent construction of a type without a factory
+ */
+ template<typename Derived>
+ struct keyed
+ {
+ protected:
+ struct key
+ {
+ };
+
+ explicit keyed(key) {}
+ };
+
+} // namespace wanda::meta
+
+#endif \ No newline at end of file
diff --git a/source/lib/include/wanda/meta/type_wrapper.hpp b/source/lib/include/wanda/meta/type_wrapper.hpp
new file mode 100644
index 0000000..1d34c09
--- /dev/null
+++ b/source/lib/include/wanda/meta/type_wrapper.hpp
@@ -0,0 +1,47 @@
+/**
+ * @file type_wrapper.hpp
+ * @author Felix Morgner (felix.morgner@gmail.com)
+ * @since 1.0.0
+ */
+
+#ifndef WANDA_META_TYPE_WRAPPER_HPP
+#define WANDA_META_TYPE_WRAPPER_HPP
+
+#include <utility>
+
+namespace wanda::meta
+{
+ /**
+ * @brief A type to create a distinct type based on an existing type
+ *
+ * @tparam InnerType The type to wrap
+ * @tparam TagType A tag type to identify the distinct type
+ */
+ template<typename InnerType, typename TagType>
+ struct type_wrapper
+ {
+ /**
+ * @brief Construct a new type wrapper object
+ */
+ explicit type_wrapper(InnerType value)
+ : m_value{std::move(value)}
+ {
+ }
+
+ /**
+ * @brief Retrieve the wrapped value with its original type
+ */
+ constexpr explicit operator InnerType const &() const { return get(); }
+
+ /**
+ * @brief Retrieve the wrapped value with its original type
+ */
+ constexpr InnerType const & get() const { return m_value; }
+
+ private:
+ InnerType m_value;
+ };
+
+} // namespace wanda::meta
+
+#endif \ No newline at end of file