mirror of
https://github.com/BlackMATov/meta.hpp.git
synced 2025-12-16 22:17:02 +07:00
extend scope function #20
This commit is contained in:
@@ -8,9 +8,7 @@
|
||||
|
||||
#include "meta_base.hpp"
|
||||
#include "meta_states.hpp"
|
||||
|
||||
#include "meta_detail/state_registry.hpp"
|
||||
#include "meta_detail/type_registry.hpp"
|
||||
#include "meta_registry.hpp"
|
||||
|
||||
namespace meta_hpp::detail
|
||||
{
|
||||
@@ -351,11 +349,7 @@ namespace meta_hpp
|
||||
{
|
||||
class scope_bind final {
|
||||
public:
|
||||
struct local_tag {};
|
||||
struct static_tag {};
|
||||
|
||||
explicit scope_bind(std::string name, metadata_map metadata, local_tag);
|
||||
explicit scope_bind(std::string_view name, metadata_map metadata, static_tag);
|
||||
explicit scope_bind(const scope& scope, metadata_map metadata);
|
||||
operator scope() const noexcept;
|
||||
|
||||
// function_
|
||||
@@ -471,10 +465,16 @@ namespace meta_hpp
|
||||
namespace meta_hpp
|
||||
{
|
||||
inline scope_bind local_scope_(std::string name, metadata_map metadata = {}) {
|
||||
return scope_bind{std::move(name), std::move(metadata), scope_bind::local_tag()};
|
||||
scope local_scope{detail::scope_state::make(std::move(name))};
|
||||
return scope_bind{local_scope, std::move(metadata)};
|
||||
}
|
||||
|
||||
inline scope_bind static_scope_(std::string_view name, metadata_map metadata = {}) {
|
||||
return scope_bind{name, std::move(metadata), scope_bind::static_tag()};
|
||||
scope static_scope{resolve_scope(name)};
|
||||
return scope_bind{static_scope, std::move(metadata)};
|
||||
}
|
||||
|
||||
inline scope_bind extend_scope_(const scope& scope, metadata_map metadata = {}) {
|
||||
return scope_bind{scope, std::move(metadata)};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,11 +12,8 @@
|
||||
|
||||
namespace meta_hpp
|
||||
{
|
||||
inline scope_bind::scope_bind(std::string name, metadata_map metadata, local_tag)
|
||||
: state_{detail::scope_state::make(std::move(name), std::move(metadata))} {}
|
||||
|
||||
inline scope_bind::scope_bind(std::string_view name, metadata_map metadata, static_tag)
|
||||
: state_{detail::state_access(resolve_scope(name))} {
|
||||
inline scope_bind::scope_bind(const scope& scope, metadata_map metadata)
|
||||
: state_{detail::state_access(scope)} {
|
||||
detail::insert_or_assign(state_->metadata, std::move(metadata));
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace meta_hpp::detail
|
||||
return iter->second;
|
||||
}
|
||||
|
||||
auto state = scope_state::make(std::string{name}, metadata_map{});
|
||||
auto state = scope_state::make(std::string{name});
|
||||
auto&& [iter, _] = scopes_.insert_or_assign(std::string{name}, std::move(state));
|
||||
return iter->second;
|
||||
}
|
||||
|
||||
@@ -600,7 +600,7 @@ namespace meta_hpp::detail
|
||||
typedef_map typedefs{};
|
||||
variable_set variables{};
|
||||
|
||||
[[nodiscard]] static scope_state_ptr make(std::string name, metadata_map metadata);
|
||||
[[nodiscard]] static scope_state_ptr make(std::string name);
|
||||
};
|
||||
|
||||
struct variable_state final {
|
||||
|
||||
@@ -19,10 +19,9 @@
|
||||
|
||||
namespace meta_hpp::detail
|
||||
{
|
||||
inline scope_state_ptr scope_state::make(std::string name, metadata_map metadata) {
|
||||
inline scope_state_ptr scope_state::make(std::string name) {
|
||||
return std::make_shared<scope_state>(scope_state{
|
||||
.index{scope_index::make(std::move(name))},
|
||||
.metadata{std::move(metadata)},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user