Merge branch 'feature/headers_cleanup' into dev

This commit is contained in:
BlackMATov
2023-07-20 22:45:01 +07:00
18 changed files with 318 additions and 151 deletions

View File

@@ -18,5 +18,11 @@ target_link_libraries(${PROJECT_NAME}.singles PRIVATE
meta.hpp.vendors::doctest
meta.hpp.vendors::fmt)
target_compile_definitions(${PROJECT_NAME} PRIVATE
META_HPP_HEADERS_BUILD)
target_compile_definitions(${PROJECT_NAME}.singles PRIVATE
META_HPP_SINGLES_BUILD)
add_test(${PROJECT_NAME} ${PROJECT_NAME})
add_test(${PROJECT_NAME} ${PROJECT_NAME}.singles)

View File

@@ -1683,6 +1683,154 @@ namespace meta_hpp
using variable_list = std::vector<variable>;
}
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<T>, //
typename = std::enable_if_t< //
!std::is_same_v<Tp, uvalue> && //
!detail::is_in_place_type_v<Tp> && //
std::is_copy_constructible_v<Tp>>> //
uvalue(T&& val);
template < //
typename T, //
typename Tp = std::decay_t<T>, //
typename = std::enable_if_t< //
!std::is_same_v<Tp, uvalue> && //
std::is_copy_constructible_v<Tp>>> //
uvalue& operator=(T&& val);
template < typename T, typename... Args, typename Tp = std::decay_t<T> >
requires std::is_copy_constructible_v<Tp> //
&& std::is_constructible_v<Tp, Args...> //
explicit uvalue(std::in_place_type_t<T>, Args&&... args);
template < typename T, typename U, typename... Args, typename Tp = std::decay_t<T> >
requires std::is_copy_constructible_v<Tp> //
&& std::is_constructible_v<Tp, std::initializer_list<U>&, Args...> //
explicit uvalue(std::in_place_type_t<T>, std::initializer_list<U> ilist, Args&&... args);
template < typename T, typename... Args, typename Tp = std::decay_t<T> >
requires std::is_copy_constructible_v<Tp> //
&& std::is_constructible_v<Tp, Args...> //
Tp& emplace(Args&&... args);
template < typename T, typename U, typename... Args, typename Tp = std::decay_t<T> >
requires std::is_copy_constructible_v<Tp> //
&& std::is_constructible_v<Tp, std::initializer_list<U>&, Args...> //
Tp& emplace(std::initializer_list<U> 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<storage_u>);
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<T>, std::forward<Args>(args)...);
}
template < typename T, typename U, typename... Args >
uvalue make_uvalue(std::initializer_list<U> ilist, Args&&... args) {
return uvalue(std::in_place_type<T>, ilist, std::forward<Args>(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<T>, //
typename = std::enable_if_t< //
!std::is_same_v<Tp, uvalue> && //
!detail::is_in_place_type_v<Tp> && //
std::is_copy_constructible_v<Tp>>> //
uvalue(T&& val);
template < //
typename T, //
typename Tp = std::decay_t<T>, //
typename = std::enable_if_t< //
!std::is_same_v<Tp, uvalue> && //
std::is_copy_constructible_v<Tp>>> //
uvalue& operator=(T&& val);
template < typename T, typename... Args, typename Tp = std::decay_t<T> >
requires std::is_copy_constructible_v<Tp> //
&& std::is_constructible_v<Tp, Args...> //
explicit uvalue(std::in_place_type_t<T>, Args&&... args);
template < typename T, typename U, typename... Args, typename Tp = std::decay_t<T> >
requires std::is_copy_constructible_v<Tp> //
&& std::is_constructible_v<Tp, std::initializer_list<U>&, Args...> //
explicit uvalue(std::in_place_type_t<T>, std::initializer_list<U> ilist, Args&&... args);
template < typename T, typename... Args, typename Tp = std::decay_t<T> >
requires std::is_copy_constructible_v<Tp> //
&& std::is_constructible_v<Tp, Args...> //
Tp& emplace(Args&&... args);
template < typename T, typename U, typename... Args, typename Tp = std::decay_t<T> >
requires std::is_copy_constructible_v<Tp> //
&& std::is_constructible_v<Tp, std::initializer_list<U>&, Args...> //
Tp& emplace(std::initializer_list<U> 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<storage_u>);
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<T>, std::forward<Args>(args)...);
}
template < typename T, typename U, typename... Args >
uvalue make_uvalue(std::initializer_list<U> ilist, Args&&... args) {
return uvalue(std::in_place_type<T>, ilist, std::forward<Args>(args)...);
}
}
namespace meta_hpp
{
class uerror final {

View File

@@ -19,3 +19,9 @@ target_link_libraries(${PROJECT_NAME}.singles PRIVATE
meta.hpp.vendors::gbench
meta.hpp.vendors::rttr
meta.hpp.vendors::vmath.hpp)
target_compile_definitions(${PROJECT_NAME} PRIVATE
META_HPP_HEADERS_BUILD)
target_compile_definitions(${PROJECT_NAME}.singles PRIVATE
META_HPP_SINGLES_BUILD)

View File

@@ -16,5 +16,11 @@ target_link_libraries(${PROJECT_NAME}.singles PRIVATE
meta.hpp::setup_targets
meta.hpp.vendors::doctest)
target_compile_definitions(${PROJECT_NAME} PRIVATE
META_HPP_HEADERS_BUILD)
target_compile_definitions(${PROJECT_NAME}.singles PRIVATE
META_HPP_SINGLES_BUILD)
add_test(${PROJECT_NAME} ${PROJECT_NAME})
add_test(${PROJECT_NAME} ${PROJECT_NAME}.singles)

View File

@@ -0,0 +1,16 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/meta.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2021-2023, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#if defined(META_HPP_HEADERS_BUILD)
# include <meta.hpp/meta_binds.hpp>
#else
# include <meta.hpp/meta_all.hpp>
#endif
#include <doctest/doctest.h>
TEST_CASE("meta/meta_headers/binds") {
}

View File

@@ -0,0 +1,16 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/meta.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2021-2023, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#if defined(META_HPP_HEADERS_BUILD)
# include <meta.hpp/meta_indices.hpp>
#else
# include <meta.hpp/meta_all.hpp>
#endif
#include <doctest/doctest.h>
TEST_CASE("meta/meta_headers/indices") {
}

View File

@@ -0,0 +1,16 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/meta.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2021-2023, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#if defined(META_HPP_HEADERS_BUILD)
# include <meta.hpp/meta_invoke.hpp>
#else
# include <meta.hpp/meta_all.hpp>
#endif
#include <doctest/doctest.h>
TEST_CASE("meta/meta_headers/invoke") {
}

View File

@@ -0,0 +1,16 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/meta.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2021-2023, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#if defined(META_HPP_HEADERS_BUILD)
# include <meta.hpp/meta_registry.hpp>
#else
# include <meta.hpp/meta_all.hpp>
#endif
#include <doctest/doctest.h>
TEST_CASE("meta/meta_headers/registry") {
}

View File

@@ -0,0 +1,16 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/meta.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2021-2023, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#if defined(META_HPP_HEADERS_BUILD)
# include <meta.hpp/meta_states.hpp>
#else
# include <meta.hpp/meta_all.hpp>
#endif
#include <doctest/doctest.h>
TEST_CASE("meta/meta_headers/states") {
}

View File

@@ -0,0 +1,16 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/meta.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2021-2023, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#if defined(META_HPP_HEADERS_BUILD)
# include <meta.hpp/meta_types.hpp>
#else
# include <meta.hpp/meta_all.hpp>
#endif
#include <doctest/doctest.h>
TEST_CASE("meta/meta_headers/types") {
}

View File

@@ -0,0 +1,16 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/meta.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2021-2023, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#if defined(META_HPP_HEADERS_BUILD)
# include <meta.hpp/meta_ucast.hpp>
#else
# include <meta.hpp/meta_all.hpp>
#endif
#include <doctest/doctest.h>
TEST_CASE("meta/meta_headers/ucast") {
}

View File

@@ -0,0 +1,16 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/meta.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2021-2023, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#if defined(META_HPP_HEADERS_BUILD)
# include <meta.hpp/meta_uresult.hpp>
#else
# include <meta.hpp/meta_all.hpp>
#endif
#include <doctest/doctest.h>
TEST_CASE("meta/meta_headers/uresult") {
}

View File

@@ -0,0 +1,16 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/meta.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2021-2023, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#if defined(META_HPP_HEADERS_BUILD)
# include <meta.hpp/meta_uvalue.hpp>
#else
# include <meta.hpp/meta_all.hpp>
#endif
#include <doctest/doctest.h>
TEST_CASE("meta/meta_headers/uvalue") {
}

View File

@@ -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
{

View File

@@ -8,6 +8,7 @@
#include "meta_base.hpp"
#include "meta_states.hpp"
#include "meta_uresult.hpp"
#include "meta_uvalue.hpp"
namespace meta_hpp

View File

@@ -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"

View File

@@ -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} {}

View File

@@ -7,7 +7,6 @@
#pragma once
#include "meta_base.hpp"
#include "meta_types.hpp"
namespace meta_hpp
{