From 7375ec0e359642138aac891c841222dd181cabff Mon Sep 17 00:00:00 2001 From: BlackMATov Date: Thu, 20 Jul 2023 22:44:50 +0700 Subject: [PATCH] little cleanup header's includes --- develop/singles/headers/meta.hpp/meta_all.hpp | 298 +++++++++--------- headers/meta.hpp/meta_binds.hpp | 2 + headers/meta.hpp/meta_invoke.hpp | 1 + headers/meta.hpp/meta_invoke/invoke.hpp | 2 + headers/meta.hpp/meta_types.hpp | 3 +- headers/meta.hpp/meta_uvalue.hpp | 1 - 6 files changed, 156 insertions(+), 151 deletions(-) diff --git a/develop/singles/headers/meta.hpp/meta_all.hpp b/develop/singles/headers/meta.hpp/meta_all.hpp index c20beb4..5327040 100644 --- a/develop/singles/headers/meta.hpp/meta_all.hpp +++ b/develop/singles/headers/meta.hpp/meta_all.hpp @@ -1683,6 +1683,154 @@ namespace meta_hpp using variable_list = std::vector; } +namespace meta_hpp +{ + class uvalue final { + public: + uvalue() = default; + ~uvalue() noexcept; + + uvalue(uvalue&& other) noexcept; + uvalue(const uvalue& other); + + uvalue& operator=(uvalue&& other) noexcept; + uvalue& operator=(const uvalue& other); + + template < // + typename T, // + typename Tp = std::decay_t, // + typename = std::enable_if_t< // + !std::is_same_v && // + !detail::is_in_place_type_v && // + std::is_copy_constructible_v>> // + uvalue(T&& val); + + template < // + typename T, // + typename Tp = std::decay_t, // + typename = std::enable_if_t< // + !std::is_same_v && // + std::is_copy_constructible_v>> // + uvalue& operator=(T&& val); + + template < typename T, typename... Args, typename Tp = std::decay_t > + requires std::is_copy_constructible_v // + && std::is_constructible_v // + explicit uvalue(std::in_place_type_t, Args&&... args); + + template < typename T, typename U, typename... Args, typename Tp = std::decay_t > + requires std::is_copy_constructible_v // + && std::is_constructible_v&, Args...> // + explicit uvalue(std::in_place_type_t, std::initializer_list ilist, Args&&... args); + + template < typename T, typename... Args, typename Tp = std::decay_t > + requires std::is_copy_constructible_v // + && std::is_constructible_v // + Tp& emplace(Args&&... args); + + template < typename T, typename U, typename... Args, typename Tp = std::decay_t > + requires std::is_copy_constructible_v // + && std::is_constructible_v&, Args...> // + Tp& emplace(std::initializer_list ilist, Args&&... args); + + [[nodiscard]] bool has_value() const noexcept; + [[nodiscard]] explicit operator bool() const noexcept; + + void reset() noexcept; + void swap(uvalue& other) noexcept; + + [[nodiscard]] any_type get_type() const noexcept; + + [[nodiscard]] void* get_data() noexcept; + [[nodiscard]] const void* get_data() const noexcept; + [[nodiscard]] const void* get_cdata() const noexcept; + + [[nodiscard]] uvalue operator*() const; + [[nodiscard]] bool has_deref_op() const noexcept; + + [[nodiscard]] uvalue operator[](std::size_t index) const; + [[nodiscard]] bool has_index_op() const noexcept; + + [[nodiscard]] uvalue unmap() const; + [[nodiscard]] bool has_unmap_op() const noexcept; + + template < typename T > + [[nodiscard]] bool is() const noexcept; + + template < detail::pointer_kind T > + [[nodiscard]] T as(); + template < detail::pointer_kind T > + [[nodiscard]] T as() const; + + template < detail::non_pointer_kind T > + [[nodiscard]] T as() &&; + template < detail::non_pointer_kind T > + [[nodiscard]] T& as() &; + template < detail::non_pointer_kind T > + [[nodiscard]] const T& as() const&; + template < detail::non_pointer_kind T > + [[nodiscard]] const T&& as() const&&; + + template < detail::pointer_kind T > + [[nodiscard]] T try_as() noexcept; + template < detail::pointer_kind T > + [[nodiscard]] T try_as() const noexcept; + + template < detail::non_pointer_kind T > + [[nodiscard]] T* try_as() noexcept; + template < detail::non_pointer_kind T > + [[nodiscard]] const T* try_as() const noexcept; + + private: + struct vtable_t; + + struct alignas(std::max_align_t) internal_storage_t final { + // NOLINTNEXTLINE(*-avoid-c-arrays) + std::byte data[sizeof(void*) * 2]; + }; + + struct external_storage_t final { + // NOLINTNEXTLINE(*-avoid-c-arrays) + std::byte padding[sizeof(internal_storage_t) - sizeof(void*)]; + void* ptr; + }; + + enum class storage_e : std::uintptr_t { + nothing, + trivial, + internal, + external, + }; + + struct storage_u final { + union { + internal_storage_t internal; + external_storage_t external; + }; + + std::uintptr_t vtag; + } storage_{}; + + static_assert(std::is_standard_layout_v); + static_assert(alignof(storage_u) == alignof(std::max_align_t)); + static_assert(sizeof(internal_storage_t) == sizeof(external_storage_t)); + }; + + inline void swap(uvalue& l, uvalue& r) noexcept { + l.swap(r); + } + + template < typename T, typename... Args > + uvalue make_uvalue(Args&&... args) { + return uvalue(std::in_place_type, std::forward(args)...); + } + + template < typename T, typename U, typename... Args > + uvalue make_uvalue(std::initializer_list ilist, Args&&... args) { + return uvalue(std::in_place_type, ilist, std::forward(args)...); + } +} + namespace meta_hpp::detail { enum class array_flags : std::uint32_t { @@ -2742,7 +2890,7 @@ namespace meta_hpp::detail const type_kind kind; // NOLINTEND(*-avoid-const-or-ref-data-members) - metadata_map metadata{}; + metadata_map metadata; explicit type_data_base(type_kind nkind) : kind{nkind} {} @@ -3112,154 +3260,6 @@ namespace std }; } -namespace meta_hpp -{ - class uvalue final { - public: - uvalue() = default; - ~uvalue() noexcept; - - uvalue(uvalue&& other) noexcept; - uvalue(const uvalue& other); - - uvalue& operator=(uvalue&& other) noexcept; - uvalue& operator=(const uvalue& other); - - template < // - typename T, // - typename Tp = std::decay_t, // - typename = std::enable_if_t< // - !std::is_same_v && // - !detail::is_in_place_type_v && // - std::is_copy_constructible_v>> // - uvalue(T&& val); - - template < // - typename T, // - typename Tp = std::decay_t, // - typename = std::enable_if_t< // - !std::is_same_v && // - std::is_copy_constructible_v>> // - uvalue& operator=(T&& val); - - template < typename T, typename... Args, typename Tp = std::decay_t > - requires std::is_copy_constructible_v // - && std::is_constructible_v // - explicit uvalue(std::in_place_type_t, Args&&... args); - - template < typename T, typename U, typename... Args, typename Tp = std::decay_t > - requires std::is_copy_constructible_v // - && std::is_constructible_v&, Args...> // - explicit uvalue(std::in_place_type_t, std::initializer_list ilist, Args&&... args); - - template < typename T, typename... Args, typename Tp = std::decay_t > - requires std::is_copy_constructible_v // - && std::is_constructible_v // - Tp& emplace(Args&&... args); - - template < typename T, typename U, typename... Args, typename Tp = std::decay_t > - requires std::is_copy_constructible_v // - && std::is_constructible_v&, Args...> // - Tp& emplace(std::initializer_list ilist, Args&&... args); - - [[nodiscard]] bool has_value() const noexcept; - [[nodiscard]] explicit operator bool() const noexcept; - - void reset() noexcept; - void swap(uvalue& other) noexcept; - - [[nodiscard]] any_type get_type() const noexcept; - - [[nodiscard]] void* get_data() noexcept; - [[nodiscard]] const void* get_data() const noexcept; - [[nodiscard]] const void* get_cdata() const noexcept; - - [[nodiscard]] uvalue operator*() const; - [[nodiscard]] bool has_deref_op() const noexcept; - - [[nodiscard]] uvalue operator[](std::size_t index) const; - [[nodiscard]] bool has_index_op() const noexcept; - - [[nodiscard]] uvalue unmap() const; - [[nodiscard]] bool has_unmap_op() const noexcept; - - template < typename T > - [[nodiscard]] bool is() const noexcept; - - template < detail::pointer_kind T > - [[nodiscard]] T as(); - template < detail::pointer_kind T > - [[nodiscard]] T as() const; - - template < detail::non_pointer_kind T > - [[nodiscard]] T as() &&; - template < detail::non_pointer_kind T > - [[nodiscard]] T& as() &; - template < detail::non_pointer_kind T > - [[nodiscard]] const T& as() const&; - template < detail::non_pointer_kind T > - [[nodiscard]] const T&& as() const&&; - - template < detail::pointer_kind T > - [[nodiscard]] T try_as() noexcept; - template < detail::pointer_kind T > - [[nodiscard]] T try_as() const noexcept; - - template < detail::non_pointer_kind T > - [[nodiscard]] T* try_as() noexcept; - template < detail::non_pointer_kind T > - [[nodiscard]] const T* try_as() const noexcept; - - private: - struct vtable_t; - - struct alignas(std::max_align_t) internal_storage_t final { - // NOLINTNEXTLINE(*-avoid-c-arrays) - std::byte data[sizeof(void*) * 2]; - }; - - struct external_storage_t final { - // NOLINTNEXTLINE(*-avoid-c-arrays) - std::byte padding[sizeof(internal_storage_t) - sizeof(void*)]; - void* ptr; - }; - - enum class storage_e : std::uintptr_t { - nothing, - trivial, - internal, - external, - }; - - struct storage_u final { - union { - internal_storage_t internal; - external_storage_t external; - }; - - std::uintptr_t vtag; - } storage_{}; - - static_assert(std::is_standard_layout_v); - static_assert(alignof(storage_u) == alignof(std::max_align_t)); - static_assert(sizeof(internal_storage_t) == sizeof(external_storage_t)); - }; - - inline void swap(uvalue& l, uvalue& r) noexcept { - l.swap(r); - } - - template < typename T, typename... Args > - uvalue make_uvalue(Args&&... args) { - return uvalue(std::in_place_type, std::forward(args)...); - } - - template < typename T, typename U, typename... Args > - uvalue make_uvalue(std::initializer_list ilist, Args&&... args) { - return uvalue(std::in_place_type, ilist, std::forward(args)...); - } -} - namespace meta_hpp { class uerror final { diff --git a/headers/meta.hpp/meta_binds.hpp b/headers/meta.hpp/meta_binds.hpp index 65d989c..9ab79d1 100644 --- a/headers/meta.hpp/meta_binds.hpp +++ b/headers/meta.hpp/meta_binds.hpp @@ -9,6 +9,8 @@ #include "meta_base.hpp" #include "meta_registry.hpp" #include "meta_states.hpp" +#include "meta_types.hpp" +#include "meta_uvalue.hpp" namespace meta_hpp::detail { diff --git a/headers/meta.hpp/meta_invoke.hpp b/headers/meta.hpp/meta_invoke.hpp index ddccc62..12e8009 100644 --- a/headers/meta.hpp/meta_invoke.hpp +++ b/headers/meta.hpp/meta_invoke.hpp @@ -8,6 +8,7 @@ #include "meta_base.hpp" #include "meta_states.hpp" +#include "meta_uresult.hpp" #include "meta_uvalue.hpp" namespace meta_hpp diff --git a/headers/meta.hpp/meta_invoke/invoke.hpp b/headers/meta.hpp/meta_invoke/invoke.hpp index b892d99..dae5908 100644 --- a/headers/meta.hpp/meta_invoke/invoke.hpp +++ b/headers/meta.hpp/meta_invoke/invoke.hpp @@ -9,6 +9,8 @@ #include "../meta_base.hpp" #include "../meta_invoke.hpp" #include "../meta_states.hpp" +#include "../meta_uresult.hpp" +#include "../meta_uvalue.hpp" #include "../meta_states/function.hpp" #include "../meta_states/member.hpp" diff --git a/headers/meta.hpp/meta_types.hpp b/headers/meta.hpp/meta_types.hpp index ba63445..2c3cbaa 100644 --- a/headers/meta.hpp/meta_types.hpp +++ b/headers/meta.hpp/meta_types.hpp @@ -7,6 +7,7 @@ #pragma once #include "meta_base.hpp" +#include "meta_uvalue.hpp" #include "meta_detail/type_family.hpp" @@ -466,7 +467,7 @@ namespace meta_hpp::detail const type_kind kind; // NOLINTEND(*-avoid-const-or-ref-data-members) - metadata_map metadata{}; + metadata_map metadata; explicit type_data_base(type_kind nkind) : kind{nkind} {} diff --git a/headers/meta.hpp/meta_uvalue.hpp b/headers/meta.hpp/meta_uvalue.hpp index dd26d9d..bc4b72a 100644 --- a/headers/meta.hpp/meta_uvalue.hpp +++ b/headers/meta.hpp/meta_uvalue.hpp @@ -7,7 +7,6 @@ #pragma once #include "meta_base.hpp" -#include "meta_types.hpp" namespace meta_hpp {