mirror of
https://github.com/BlackMATov/meta.hpp.git
synced 2025-12-15 03:45:30 +07:00
add kari.hpp and enum.hpp as submodules
This commit is contained in:
6
.gitmodules
vendored
Normal file
6
.gitmodules
vendored
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
[submodule "vendors/enum.hpp"]
|
||||||
|
path = vendors/enum.hpp
|
||||||
|
url = https://github.com/BlackMATov/enum.hpp
|
||||||
|
[submodule "vendors/kari.hpp"]
|
||||||
|
path = vendors/kari.hpp
|
||||||
|
url = https://github.com/BlackMATov/kari.hpp
|
||||||
@@ -7,9 +7,19 @@ endif()
|
|||||||
|
|
||||||
project(meta.hpp)
|
project(meta.hpp)
|
||||||
|
|
||||||
|
add_subdirectory(vendors/enum.hpp)
|
||||||
|
add_subdirectory(vendors/kari.hpp)
|
||||||
|
|
||||||
add_library(${PROJECT_NAME} INTERFACE)
|
add_library(${PROJECT_NAME} INTERFACE)
|
||||||
target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_17)
|
|
||||||
target_include_directories(${PROJECT_NAME} INTERFACE headers)
|
target_link_libraries(${PROJECT_NAME}
|
||||||
|
INTERFACE enum.hpp kari.hpp)
|
||||||
|
|
||||||
|
target_compile_features(${PROJECT_NAME}
|
||||||
|
INTERFACE cxx_std_17)
|
||||||
|
|
||||||
|
target_include_directories(${PROJECT_NAME}
|
||||||
|
INTERFACE headers)
|
||||||
|
|
||||||
if(BUILD_AS_STANDALONE)
|
if(BUILD_AS_STANDALONE)
|
||||||
option(BUILD_WITH_UNTESTS "Build with unit tests" ON)
|
option(BUILD_WITH_UNTESTS "Build with unit tests" ON)
|
||||||
|
|||||||
@@ -27,6 +27,11 @@
|
|||||||
#include <variant>
|
#include <variant>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include <enum.hpp/enum.hpp>
|
||||||
|
#include <enum.hpp/enum_bitflags.hpp>
|
||||||
|
|
||||||
|
#include <kari.hpp/kari.hpp>
|
||||||
|
|
||||||
namespace meta_hpp
|
namespace meta_hpp
|
||||||
{
|
{
|
||||||
class class_info;
|
class class_info;
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#include "meta_infos.hpp"
|
#include "meta_infos.hpp"
|
||||||
|
|
||||||
#include "meta_registry/class_.hpp"
|
#include "meta_registry/class_.hpp"
|
||||||
|
#include "meta_registry/ctor_.hpp"
|
||||||
#include "meta_registry/data_.hpp"
|
#include "meta_registry/data_.hpp"
|
||||||
#include "meta_registry/enum_.hpp"
|
#include "meta_registry/enum_.hpp"
|
||||||
#include "meta_registry/evalue_.hpp"
|
#include "meta_registry/evalue_.hpp"
|
||||||
@@ -164,7 +165,7 @@ namespace meta_hpp
|
|||||||
|
|
||||||
inline void registry::add_info_(const std::string& prefix, const class_info& info) {
|
inline void registry::add_info_(const std::string& prefix, const class_info& info) {
|
||||||
std::string name = prefix.empty() ? info.name() : prefix + "::" + info.name();
|
std::string name = prefix.empty() ? info.name() : prefix + "::" + info.name();
|
||||||
info.visit(curry(add_info_f{}, std::ref(*this), name));
|
info.visit(kari_hpp::curry(add_info_f{}, std::ref(*this), name));
|
||||||
detail::merge_with(classes_, name, info, &class_info::merge);
|
detail::merge_with(classes_, name, info, &class_info::merge);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,43 +176,43 @@ namespace meta_hpp
|
|||||||
|
|
||||||
inline void registry::add_info_(const std::string& prefix, const data_info& info) {
|
inline void registry::add_info_(const std::string& prefix, const data_info& info) {
|
||||||
std::string name = prefix.empty() ? info.name() : prefix + "::" + info.name();
|
std::string name = prefix.empty() ? info.name() : prefix + "::" + info.name();
|
||||||
info.visit(curry(add_info_f{}, std::ref(*this), name));
|
info.visit(kari_hpp::curry(add_info_f{}, std::ref(*this), name));
|
||||||
detail::merge_with(datas_, name, info, &data_info::merge);
|
detail::merge_with(datas_, name, info, &data_info::merge);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void registry::add_info_(const std::string& prefix, const enum_info& info) {
|
inline void registry::add_info_(const std::string& prefix, const enum_info& info) {
|
||||||
std::string name = prefix.empty() ? info.name() : prefix + "::" + info.name();
|
std::string name = prefix.empty() ? info.name() : prefix + "::" + info.name();
|
||||||
info.visit(curry(add_info_f{}, std::ref(*this), name));
|
info.visit(kari_hpp::curry(add_info_f{}, std::ref(*this), name));
|
||||||
detail::merge_with(enums_, name, info, &enum_info::merge);
|
detail::merge_with(enums_, name, info, &enum_info::merge);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void registry::add_info_(const std::string& prefix, const evalue_info& info) {
|
inline void registry::add_info_(const std::string& prefix, const evalue_info& info) {
|
||||||
std::string name = prefix.empty() ? info.name() : prefix + "::" + info.name();
|
std::string name = prefix.empty() ? info.name() : prefix + "::" + info.name();
|
||||||
info.visit(curry(add_info_f{}, std::ref(*this), name));
|
info.visit(kari_hpp::curry(add_info_f{}, std::ref(*this), name));
|
||||||
detail::merge_with(evalues_, name, info, &evalue_info::merge);
|
detail::merge_with(evalues_, name, info, &evalue_info::merge);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void registry::add_info_(const std::string& prefix, const function_info& info) {
|
inline void registry::add_info_(const std::string& prefix, const function_info& info) {
|
||||||
std::string name = prefix.empty() ? info.name() : prefix + "::" + info.name();
|
std::string name = prefix.empty() ? info.name() : prefix + "::" + info.name();
|
||||||
info.visit(curry(add_info_f{}, std::ref(*this), name));
|
info.visit(kari_hpp::curry(add_info_f{}, std::ref(*this), name));
|
||||||
detail::merge_with(functions_, name, info, &function_info::merge);
|
detail::merge_with(functions_, name, info, &function_info::merge);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void registry::add_info_(const std::string& prefix, const member_info& info) {
|
inline void registry::add_info_(const std::string& prefix, const member_info& info) {
|
||||||
std::string name = prefix.empty() ? info.name() : prefix + "::" + info.name();
|
std::string name = prefix.empty() ? info.name() : prefix + "::" + info.name();
|
||||||
info.visit(curry(add_info_f{}, std::ref(*this), name));
|
info.visit(kari_hpp::curry(add_info_f{}, std::ref(*this), name));
|
||||||
detail::merge_with(members_, name, info, &member_info::merge);
|
detail::merge_with(members_, name, info, &member_info::merge);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void registry::add_info_(const std::string& prefix, const method_info& info) {
|
inline void registry::add_info_(const std::string& prefix, const method_info& info) {
|
||||||
std::string name = prefix.empty() ? info.name() : prefix + "::" + info.name();
|
std::string name = prefix.empty() ? info.name() : prefix + "::" + info.name();
|
||||||
info.visit(curry(add_info_f{}, std::ref(*this), name));
|
info.visit(kari_hpp::curry(add_info_f{}, std::ref(*this), name));
|
||||||
detail::merge_with(methods_, name, info, &method_info::merge);
|
detail::merge_with(methods_, name, info, &method_info::merge);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void registry::add_info_(const std::string& prefix, const namespace_info& info) {
|
inline void registry::add_info_(const std::string& prefix, const namespace_info& info) {
|
||||||
std::string name = prefix.empty() ? info.name() : prefix + "::" + info.name();
|
std::string name = prefix.empty() ? info.name() : prefix + "::" + info.name();
|
||||||
info.visit(curry(add_info_f{}, std::ref(*this), name));
|
info.visit(kari_hpp::curry(add_info_f{}, std::ref(*this), name));
|
||||||
detail::merge_with(namespaces_, name, info, &namespace_info::merge);
|
detail::merge_with(namespaces_, name, info, &namespace_info::merge);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,5 +8,5 @@
|
|||||||
|
|
||||||
#include "meta_fwd.hpp"
|
#include "meta_fwd.hpp"
|
||||||
|
|
||||||
#include "meta_utilities/curry.hpp"
|
#include "meta_utilities/arg.hpp"
|
||||||
#include "meta_utilities/value.hpp"
|
#include "meta_utilities/value.hpp"
|
||||||
|
|||||||
@@ -1,104 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
* 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, by Matvey Cherevko (blackmatov@gmail.com)
|
|
||||||
******************************************************************************/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "../meta_fwd.hpp"
|
|
||||||
|
|
||||||
namespace meta_hpp
|
|
||||||
{
|
|
||||||
template < typename F, typename... As >
|
|
||||||
class curry_t;
|
|
||||||
|
|
||||||
namespace impl
|
|
||||||
{
|
|
||||||
template < typename F >
|
|
||||||
struct is_curried_impl
|
|
||||||
: std::false_type {};
|
|
||||||
|
|
||||||
template < typename F, typename... As >
|
|
||||||
struct is_curried_impl<curry_t<F, As...>>
|
|
||||||
: std::true_type {};
|
|
||||||
}
|
|
||||||
|
|
||||||
template < typename F >
|
|
||||||
struct is_curried
|
|
||||||
: impl::is_curried_impl<std::remove_cv_t<F>> {};
|
|
||||||
|
|
||||||
template < typename F >
|
|
||||||
inline constexpr bool is_curried_v = is_curried<F>::value;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace meta_hpp::detail
|
|
||||||
{
|
|
||||||
template < typename F, typename... Args >
|
|
||||||
constexpr auto curry_or_apply(F&& f, std::tuple<Args...>&& args) {
|
|
||||||
if constexpr ( std::is_invocable_v<std::decay_t<F>, Args...> ) {
|
|
||||||
return std::apply(std::forward<F>(f), std::move(args));
|
|
||||||
} else {
|
|
||||||
return curry_t(std::forward<F>(f), std::move(args));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace meta_hpp
|
|
||||||
{
|
|
||||||
template < typename F, typename... Args >
|
|
||||||
class curry_t final {
|
|
||||||
public:
|
|
||||||
constexpr curry_t(F f)
|
|
||||||
: f_(std::move(f)) {}
|
|
||||||
|
|
||||||
constexpr curry_t(F f, std::tuple<Args...> args)
|
|
||||||
: f_(std::move(f))
|
|
||||||
, args_(std::move(args)) {}
|
|
||||||
|
|
||||||
constexpr auto operator()() && {
|
|
||||||
return detail::curry_or_apply(
|
|
||||||
std::move(f_),
|
|
||||||
std::move(args_));
|
|
||||||
}
|
|
||||||
|
|
||||||
template < typename A >
|
|
||||||
constexpr auto operator()(A&& a) && {
|
|
||||||
return detail::curry_or_apply(
|
|
||||||
std::move(f_),
|
|
||||||
std::tuple_cat(
|
|
||||||
std::move(args_),
|
|
||||||
std::make_tuple(std::forward<A>(a))));
|
|
||||||
}
|
|
||||||
|
|
||||||
template < typename A, typename... As >
|
|
||||||
constexpr auto operator()(A&& a, As&&... as) && {
|
|
||||||
return std::move(*this)(std::forward<A>(a))(std::forward<As>(as)...);
|
|
||||||
}
|
|
||||||
|
|
||||||
template < typename... As >
|
|
||||||
constexpr auto operator()(As&&... as) const & {
|
|
||||||
return std::move(curry_t(*this))(std::forward<As>(as)...);
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
F f_;
|
|
||||||
std::tuple<Args...> args_;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace meta_hpp
|
|
||||||
{
|
|
||||||
template < typename F >
|
|
||||||
constexpr auto curry(F&& f) {
|
|
||||||
if constexpr ( is_curried_v<std::decay_t<F>> ) {
|
|
||||||
return std::forward<F>(f);
|
|
||||||
} else {
|
|
||||||
return detail::curry_or_apply(std::forward<F>(f), {});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template < typename F, typename A, typename... As >
|
|
||||||
constexpr auto curry(F&& f, A&& a, As&&... as) {
|
|
||||||
return curry(std::forward<F>(f))(std::forward<A>(a), std::forward<As>(as)...);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -29,9 +29,9 @@ target_compile_options(${PROJECT_NAME}
|
|||||||
-Werror -Wall -Wextra -Wpedantic>
|
-Werror -Wall -Wextra -Wpedantic>
|
||||||
PRIVATE
|
PRIVATE
|
||||||
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:
|
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:
|
||||||
-Werror -Weverything -Wno-unknown-warning-option
|
-Werror -Weverything -Wconversion -Wno-unknown-warning-option
|
||||||
-Wconversion -Wimplicit-int-float-conversion
|
-Wno-padded
|
||||||
-Wno-c++98-compat-pedantic -Wno-ctad-maybe-unsupported -Wno-padded
|
-Wno-c++98-compat-pedantic
|
||||||
-Wno-float-equal -Wno-double-promotion -Wno-shadow-field-in-constructor>)
|
-Wno-shadow-field-in-constructor>)
|
||||||
|
|
||||||
add_test(${PROJECT_NAME} ${PROJECT_NAME})
|
add_test(${PROJECT_NAME} ${PROJECT_NAME})
|
||||||
|
|||||||
1
vendors/enum.hpp
vendored
Submodule
1
vendors/enum.hpp
vendored
Submodule
Submodule vendors/enum.hpp added at 0a549d3341
1
vendors/kari.hpp
vendored
Submodule
1
vendors/kari.hpp
vendored
Submodule
Submodule vendors/kari.hpp added at c52226f855
Reference in New Issue
Block a user