mirror of
https://github.com/BlackMATov/meta.hpp.git
synced 2025-12-15 03:45:30 +07:00
remove meta_hpp::stdex namespace
This commit is contained in:
@@ -39,10 +39,11 @@
|
|||||||
#include "meta_base/cvref_traits.hpp"
|
#include "meta_base/cvref_traits.hpp"
|
||||||
#include "meta_base/fixed_function.hpp"
|
#include "meta_base/fixed_function.hpp"
|
||||||
#include "meta_base/hash_combiner.hpp"
|
#include "meta_base/hash_combiner.hpp"
|
||||||
|
#include "meta_base/is_in_place_type.hpp"
|
||||||
#include "meta_base/noncopyable.hpp"
|
#include "meta_base/noncopyable.hpp"
|
||||||
#include "meta_base/overloaded.hpp"
|
#include "meta_base/overloaded.hpp"
|
||||||
#include "meta_base/select_overload.hpp"
|
#include "meta_base/select_overload.hpp"
|
||||||
#include "meta_base/stdex.hpp"
|
#include "meta_base/to_underlying.hpp"
|
||||||
#include "meta_base/type_id.hpp"
|
#include "meta_base/type_id.hpp"
|
||||||
#include "meta_base/type_kinds.hpp"
|
#include "meta_base/type_kinds.hpp"
|
||||||
#include "meta_base/type_list.hpp"
|
#include "meta_base/type_list.hpp"
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
namespace meta_hpp::stdex
|
namespace meta_hpp::detail
|
||||||
{
|
{
|
||||||
template < typename T >
|
template < typename T >
|
||||||
struct is_in_place_type : std::false_type {};
|
struct is_in_place_type : std::false_type {};
|
||||||
@@ -20,11 +20,3 @@ namespace meta_hpp::stdex
|
|||||||
template < typename T >
|
template < typename T >
|
||||||
inline constexpr bool is_in_place_type_v = is_in_place_type<T>::value;
|
inline constexpr bool is_in_place_type_v = is_in_place_type<T>::value;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace meta_hpp::stdex
|
|
||||||
{
|
|
||||||
template < typename Enum >
|
|
||||||
[[nodiscard]] constexpr std::underlying_type_t<Enum> to_underlying(Enum e) noexcept {
|
|
||||||
return static_cast<std::underlying_type_t<Enum>>(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
17
headers/meta.hpp/meta_base/to_underlying.hpp
Normal file
17
headers/meta.hpp/meta_base/to_underlying.hpp
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* 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-2022, by Matvey Cherevko (blackmatov@gmail.com)
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
|
namespace meta_hpp::detail
|
||||||
|
{
|
||||||
|
template < typename Enum >
|
||||||
|
[[nodiscard]] constexpr std::underlying_type_t<Enum> to_underlying(Enum e) noexcept {
|
||||||
|
return static_cast<std::underlying_type_t<Enum>>(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -87,7 +87,7 @@ namespace meta_hpp::detail
|
|||||||
|
|
||||||
template < class_kind Class, typename... Args >
|
template < class_kind Class, typename... Args >
|
||||||
argument_list make_constructor_arguments() {
|
argument_list make_constructor_arguments() {
|
||||||
using ct = detail::constructor_traits<Class, Args...>;
|
using ct = constructor_traits<Class, Args...>;
|
||||||
using ct_argument_types = typename ct::argument_types;
|
using ct_argument_types = typename ct::argument_types;
|
||||||
|
|
||||||
argument_list arguments;
|
argument_list arguments;
|
||||||
@@ -95,8 +95,8 @@ namespace meta_hpp::detail
|
|||||||
|
|
||||||
[&arguments]<std::size_t... Is>(std::index_sequence<Is...>) mutable {
|
[&arguments]<std::size_t... Is>(std::index_sequence<Is...>) mutable {
|
||||||
[[maybe_unused]] const auto make_argument = []<std::size_t I>(std::index_sequence<I>){
|
[[maybe_unused]] const auto make_argument = []<std::size_t I>(std::index_sequence<I>){
|
||||||
using P = detail::type_list_at_t<I, ct_argument_types>;
|
using P = type_list_at_t<I, ct_argument_types>;
|
||||||
return argument{detail::argument_state::make<P>(I, metadata_map{})};
|
return argument{argument_state::make<P>(I, metadata_map{})};
|
||||||
};
|
};
|
||||||
(arguments.push_back(make_argument(std::index_sequence<Is>{})), ...);
|
(arguments.push_back(make_argument(std::index_sequence<Is>{})), ...);
|
||||||
}(std::make_index_sequence<ct::arity>());
|
}(std::make_index_sequence<ct::arity>());
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace meta_hpp::detail
|
|||||||
.index{evalue_index::make<Enum>(std::move(name))},
|
.index{evalue_index::make<Enum>(std::move(name))},
|
||||||
.metadata{std::move(metadata)},
|
.metadata{std::move(metadata)},
|
||||||
.enum_value{uvalue{evalue}},
|
.enum_value{uvalue{evalue}},
|
||||||
.underlying_value{uvalue{stdex::to_underlying(evalue)}},
|
.underlying_value{uvalue{to_underlying(evalue)}},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ namespace meta_hpp::detail
|
|||||||
|
|
||||||
template < function_kind Function >
|
template < function_kind Function >
|
||||||
argument_list make_function_arguments() {
|
argument_list make_function_arguments() {
|
||||||
using ft = detail::function_traits<Function>;
|
using ft = function_traits<Function>;
|
||||||
using ft_argument_types = typename ft::argument_types;
|
using ft_argument_types = typename ft::argument_types;
|
||||||
|
|
||||||
argument_list arguments;
|
argument_list arguments;
|
||||||
@@ -103,8 +103,8 @@ namespace meta_hpp::detail
|
|||||||
|
|
||||||
[&arguments]<std::size_t... Is>(std::index_sequence<Is...>) mutable {
|
[&arguments]<std::size_t... Is>(std::index_sequence<Is...>) mutable {
|
||||||
[[maybe_unused]] const auto make_argument = []<std::size_t I>(std::index_sequence<I>){
|
[[maybe_unused]] const auto make_argument = []<std::size_t I>(std::index_sequence<I>){
|
||||||
using P = detail::type_list_at_t<I, ft_argument_types>;
|
using P = type_list_at_t<I, ft_argument_types>;
|
||||||
return argument{detail::argument_state::make<P>(I, metadata_map{})};
|
return argument{argument_state::make<P>(I, metadata_map{})};
|
||||||
};
|
};
|
||||||
(arguments.push_back(make_argument(std::index_sequence<Is>{})), ...);
|
(arguments.push_back(make_argument(std::index_sequence<Is>{})), ...);
|
||||||
}(std::make_index_sequence<ft::arity>());
|
}(std::make_index_sequence<ft::arity>());
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ namespace meta_hpp::detail
|
|||||||
|
|
||||||
template < method_kind Method >
|
template < method_kind Method >
|
||||||
argument_list make_method_arguments() {
|
argument_list make_method_arguments() {
|
||||||
using mt = detail::method_traits<Method>;
|
using mt = method_traits<Method>;
|
||||||
using mt_argument_types = typename mt::argument_types;
|
using mt_argument_types = typename mt::argument_types;
|
||||||
|
|
||||||
argument_list arguments;
|
argument_list arguments;
|
||||||
@@ -114,8 +114,8 @@ namespace meta_hpp::detail
|
|||||||
|
|
||||||
[&arguments]<std::size_t... Is>(std::index_sequence<Is...>) mutable {
|
[&arguments]<std::size_t... Is>(std::index_sequence<Is...>) mutable {
|
||||||
[[maybe_unused]] const auto make_argument = []<std::size_t I>(std::index_sequence<I>){
|
[[maybe_unused]] const auto make_argument = []<std::size_t I>(std::index_sequence<I>){
|
||||||
using P = detail::type_list_at_t<I, mt_argument_types>;
|
using P = type_list_at_t<I, mt_argument_types>;
|
||||||
return argument{detail::argument_state::make<P>(I, metadata_map{})};
|
return argument{argument_state::make<P>(I, metadata_map{})};
|
||||||
};
|
};
|
||||||
(arguments.push_back(make_argument(std::index_sequence<Is>{})), ...);
|
(arguments.push_back(make_argument(std::index_sequence<Is>{})), ...);
|
||||||
}(std::make_index_sequence<mt::arity>());
|
}(std::make_index_sequence<mt::arity>());
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ namespace meta_hpp
|
|||||||
|
|
||||||
template < detail::decay_non_value_kind T >
|
template < detail::decay_non_value_kind T >
|
||||||
requires std::is_copy_constructible_v<std::decay_t<T>>
|
requires std::is_copy_constructible_v<std::decay_t<T>>
|
||||||
&& (!stdex::is_in_place_type_v<std::remove_cvref_t<T>>)
|
&& (!detail::is_in_place_type_v<std::remove_cvref_t<T>>)
|
||||||
// NOLINTNEXTLINE(*-forwarding-reference-overload)
|
// NOLINTNEXTLINE(*-forwarding-reference-overload)
|
||||||
explicit uvalue(T&& val);
|
explicit uvalue(T&& val);
|
||||||
|
|
||||||
|
|||||||
@@ -257,7 +257,7 @@ namespace meta_hpp
|
|||||||
|
|
||||||
template < detail::decay_non_value_kind T >
|
template < detail::decay_non_value_kind T >
|
||||||
requires std::is_copy_constructible_v<std::decay_t<T>>
|
requires std::is_copy_constructible_v<std::decay_t<T>>
|
||||||
&& (!stdex::is_in_place_type_v<std::remove_cvref_t<T>>)
|
&& (!detail::is_in_place_type_v<std::remove_cvref_t<T>>)
|
||||||
// NOLINTNEXTLINE(*-forwarding-reference-overload)
|
// NOLINTNEXTLINE(*-forwarding-reference-overload)
|
||||||
uvalue::uvalue(T&& val) {
|
uvalue::uvalue(T&& val) {
|
||||||
vtable_t::construct<T>(*this, std::forward<T>(val));
|
vtable_t::construct<T>(*this, std::forward<T>(val));
|
||||||
|
|||||||
@@ -495,6 +495,18 @@ namespace meta_hpp::detail
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace meta_hpp::detail
|
||||||
|
{
|
||||||
|
template < typename T >
|
||||||
|
struct is_in_place_type : std::false_type {};
|
||||||
|
|
||||||
|
template < typename U >
|
||||||
|
struct is_in_place_type<std::in_place_type_t<U>> : std::true_type {};
|
||||||
|
|
||||||
|
template < typename T >
|
||||||
|
inline constexpr bool is_in_place_type_v = is_in_place_type<T>::value;
|
||||||
|
}
|
||||||
|
|
||||||
namespace meta_hpp::detail
|
namespace meta_hpp::detail
|
||||||
{
|
{
|
||||||
class noncopyable {
|
class noncopyable {
|
||||||
@@ -553,19 +565,7 @@ namespace meta_hpp::detail
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace meta_hpp::stdex
|
namespace meta_hpp::detail
|
||||||
{
|
|
||||||
template < typename T >
|
|
||||||
struct is_in_place_type : std::false_type {};
|
|
||||||
|
|
||||||
template < typename U >
|
|
||||||
struct is_in_place_type<std::in_place_type_t<U>> : std::true_type {};
|
|
||||||
|
|
||||||
template < typename T >
|
|
||||||
inline constexpr bool is_in_place_type_v = is_in_place_type<T>::value;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace meta_hpp::stdex
|
|
||||||
{
|
{
|
||||||
template < typename Enum >
|
template < typename Enum >
|
||||||
[[nodiscard]] constexpr std::underlying_type_t<Enum> to_underlying(Enum e) noexcept {
|
[[nodiscard]] constexpr std::underlying_type_t<Enum> to_underlying(Enum e) noexcept {
|
||||||
@@ -2228,7 +2228,7 @@ namespace meta_hpp
|
|||||||
|
|
||||||
template < detail::decay_non_value_kind T >
|
template < detail::decay_non_value_kind T >
|
||||||
requires std::is_copy_constructible_v<std::decay_t<T>>
|
requires std::is_copy_constructible_v<std::decay_t<T>>
|
||||||
&& (!stdex::is_in_place_type_v<std::remove_cvref_t<T>>)
|
&& (!detail::is_in_place_type_v<std::remove_cvref_t<T>>)
|
||||||
// NOLINTNEXTLINE(*-forwarding-reference-overload)
|
// NOLINTNEXTLINE(*-forwarding-reference-overload)
|
||||||
explicit uvalue(T&& val);
|
explicit uvalue(T&& val);
|
||||||
|
|
||||||
@@ -5227,7 +5227,7 @@ namespace meta_hpp::detail
|
|||||||
|
|
||||||
template < class_kind Class, typename... Args >
|
template < class_kind Class, typename... Args >
|
||||||
argument_list make_constructor_arguments() {
|
argument_list make_constructor_arguments() {
|
||||||
using ct = detail::constructor_traits<Class, Args...>;
|
using ct = constructor_traits<Class, Args...>;
|
||||||
using ct_argument_types = typename ct::argument_types;
|
using ct_argument_types = typename ct::argument_types;
|
||||||
|
|
||||||
argument_list arguments;
|
argument_list arguments;
|
||||||
@@ -5235,8 +5235,8 @@ namespace meta_hpp::detail
|
|||||||
|
|
||||||
[&arguments]<std::size_t... Is>(std::index_sequence<Is...>) mutable {
|
[&arguments]<std::size_t... Is>(std::index_sequence<Is...>) mutable {
|
||||||
[[maybe_unused]] const auto make_argument = []<std::size_t I>(std::index_sequence<I>){
|
[[maybe_unused]] const auto make_argument = []<std::size_t I>(std::index_sequence<I>){
|
||||||
using P = detail::type_list_at_t<I, ct_argument_types>;
|
using P = type_list_at_t<I, ct_argument_types>;
|
||||||
return argument{detail::argument_state::make<P>(I, metadata_map{})};
|
return argument{argument_state::make<P>(I, metadata_map{})};
|
||||||
};
|
};
|
||||||
(arguments.push_back(make_argument(std::index_sequence<Is>{})), ...);
|
(arguments.push_back(make_argument(std::index_sequence<Is>{})), ...);
|
||||||
}(std::make_index_sequence<ct::arity>());
|
}(std::make_index_sequence<ct::arity>());
|
||||||
@@ -5573,7 +5573,7 @@ namespace meta_hpp::detail
|
|||||||
.index{evalue_index::make<Enum>(std::move(name))},
|
.index{evalue_index::make<Enum>(std::move(name))},
|
||||||
.metadata{std::move(metadata)},
|
.metadata{std::move(metadata)},
|
||||||
.enum_value{uvalue{evalue}},
|
.enum_value{uvalue{evalue}},
|
||||||
.underlying_value{uvalue{stdex::to_underlying(evalue)}},
|
.underlying_value{uvalue{to_underlying(evalue)}},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5759,7 +5759,7 @@ namespace meta_hpp::detail
|
|||||||
|
|
||||||
template < function_kind Function >
|
template < function_kind Function >
|
||||||
argument_list make_function_arguments() {
|
argument_list make_function_arguments() {
|
||||||
using ft = detail::function_traits<Function>;
|
using ft = function_traits<Function>;
|
||||||
using ft_argument_types = typename ft::argument_types;
|
using ft_argument_types = typename ft::argument_types;
|
||||||
|
|
||||||
argument_list arguments;
|
argument_list arguments;
|
||||||
@@ -5767,8 +5767,8 @@ namespace meta_hpp::detail
|
|||||||
|
|
||||||
[&arguments]<std::size_t... Is>(std::index_sequence<Is...>) mutable {
|
[&arguments]<std::size_t... Is>(std::index_sequence<Is...>) mutable {
|
||||||
[[maybe_unused]] const auto make_argument = []<std::size_t I>(std::index_sequence<I>){
|
[[maybe_unused]] const auto make_argument = []<std::size_t I>(std::index_sequence<I>){
|
||||||
using P = detail::type_list_at_t<I, ft_argument_types>;
|
using P = type_list_at_t<I, ft_argument_types>;
|
||||||
return argument{detail::argument_state::make<P>(I, metadata_map{})};
|
return argument{argument_state::make<P>(I, metadata_map{})};
|
||||||
};
|
};
|
||||||
(arguments.push_back(make_argument(std::index_sequence<Is>{})), ...);
|
(arguments.push_back(make_argument(std::index_sequence<Is>{})), ...);
|
||||||
}(std::make_index_sequence<ft::arity>());
|
}(std::make_index_sequence<ft::arity>());
|
||||||
@@ -6542,7 +6542,7 @@ namespace meta_hpp::detail
|
|||||||
|
|
||||||
template < method_kind Method >
|
template < method_kind Method >
|
||||||
argument_list make_method_arguments() {
|
argument_list make_method_arguments() {
|
||||||
using mt = detail::method_traits<Method>;
|
using mt = method_traits<Method>;
|
||||||
using mt_argument_types = typename mt::argument_types;
|
using mt_argument_types = typename mt::argument_types;
|
||||||
|
|
||||||
argument_list arguments;
|
argument_list arguments;
|
||||||
@@ -6550,8 +6550,8 @@ namespace meta_hpp::detail
|
|||||||
|
|
||||||
[&arguments]<std::size_t... Is>(std::index_sequence<Is...>) mutable {
|
[&arguments]<std::size_t... Is>(std::index_sequence<Is...>) mutable {
|
||||||
[[maybe_unused]] const auto make_argument = []<std::size_t I>(std::index_sequence<I>){
|
[[maybe_unused]] const auto make_argument = []<std::size_t I>(std::index_sequence<I>){
|
||||||
using P = detail::type_list_at_t<I, mt_argument_types>;
|
using P = type_list_at_t<I, mt_argument_types>;
|
||||||
return argument{detail::argument_state::make<P>(I, metadata_map{})};
|
return argument{argument_state::make<P>(I, metadata_map{})};
|
||||||
};
|
};
|
||||||
(arguments.push_back(make_argument(std::index_sequence<Is>{})), ...);
|
(arguments.push_back(make_argument(std::index_sequence<Is>{})), ...);
|
||||||
}(std::make_index_sequence<mt::arity>());
|
}(std::make_index_sequence<mt::arity>());
|
||||||
@@ -8260,7 +8260,7 @@ namespace meta_hpp
|
|||||||
|
|
||||||
template < detail::decay_non_value_kind T >
|
template < detail::decay_non_value_kind T >
|
||||||
requires std::is_copy_constructible_v<std::decay_t<T>>
|
requires std::is_copy_constructible_v<std::decay_t<T>>
|
||||||
&& (!stdex::is_in_place_type_v<std::remove_cvref_t<T>>)
|
&& (!detail::is_in_place_type_v<std::remove_cvref_t<T>>)
|
||||||
// NOLINTNEXTLINE(*-forwarding-reference-overload)
|
// NOLINTNEXTLINE(*-forwarding-reference-overload)
|
||||||
uvalue::uvalue(T&& val) {
|
uvalue::uvalue(T&& val) {
|
||||||
vtable_t::construct<T>(*this, std::forward<T>(val));
|
vtable_t::construct<T>(*this, std::forward<T>(val));
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ TEST_CASE("meta/meta_states/evalue") {
|
|||||||
CHECK(evalue.get_value() == color::green);
|
CHECK(evalue.get_value() == color::green);
|
||||||
CHECK(evalue.get_value().get_type() == color_type);
|
CHECK(evalue.get_value().get_type() == color_type);
|
||||||
|
|
||||||
CHECK(evalue.get_underlying_value() == meta::stdex::to_underlying(color::green));
|
CHECK(evalue.get_underlying_value() == meta::detail::to_underlying(color::green));
|
||||||
CHECK(evalue.get_underlying_value().get_type() == color_type.get_underlying_type());
|
CHECK(evalue.get_underlying_value().get_type() == color_type.get_underlying_type());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ TEST_CASE("meta/meta_types/enum_type") {
|
|||||||
const meta::evalue green_value = color_type.get_evalue("green");
|
const meta::evalue green_value = color_type.get_evalue("green");
|
||||||
REQUIRE(green_value);
|
REQUIRE(green_value);
|
||||||
CHECK(green_value.get_value() == color::green);
|
CHECK(green_value.get_value() == color::green);
|
||||||
CHECK(green_value.get_underlying_value() == meta::stdex::to_underlying(color::green));
|
CHECK(green_value.get_underlying_value() == meta::detail::to_underlying(color::green));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -107,7 +107,7 @@ TEST_CASE("meta/meta_types/enum_type") {
|
|||||||
const meta::evalue green_value = ecolor_type.get_evalue("green");
|
const meta::evalue green_value = ecolor_type.get_evalue("green");
|
||||||
REQUIRE(green_value);
|
REQUIRE(green_value);
|
||||||
CHECK(green_value.get_value() == ecolor_green);
|
CHECK(green_value.get_value() == ecolor_green);
|
||||||
CHECK(green_value.get_underlying_value() == meta::stdex::to_underlying(ecolor_green));
|
CHECK(green_value.get_underlying_value() == meta::detail::to_underlying(ecolor_green));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user