From 577fc0845718ed8ad5bebf02a277c0579a817f77 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Fri, 17 May 2024 17:58:38 +0200 Subject: wanda: restructure source layout --- source/lib/include/wanda/meta/deferred_failure.hpp | 21 ++++++++++ source/lib/include/wanda/meta/keyed.hpp | 28 +++++++++++++ source/lib/include/wanda/meta/type_wrapper.hpp | 47 ++++++++++++++++++++++ 3 files changed, 96 insertions(+) create mode 100644 source/lib/include/wanda/meta/deferred_failure.hpp create mode 100644 source/lib/include/wanda/meta/keyed.hpp create mode 100644 source/lib/include/wanda/meta/type_wrapper.hpp (limited to 'source/lib/include/wanda/meta') 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 + +namespace wanda::meta +{ + /** + * @brief A helper type to defer static_assert failures + */ + template + 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 + 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 + +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 + 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 -- cgit v1.2.3