mirror of
https://github.com/BlackMATov/meta.hpp.git
synced 2025-12-16 14:09:02 +07:00
parameter_index
This commit is contained in:
@@ -20,6 +20,7 @@
|
|||||||
#include "meta_indices/function_index.hpp"
|
#include "meta_indices/function_index.hpp"
|
||||||
#include "meta_indices/member_index.hpp"
|
#include "meta_indices/member_index.hpp"
|
||||||
#include "meta_indices/method_index.hpp"
|
#include "meta_indices/method_index.hpp"
|
||||||
|
#include "meta_indices/parameter_index.hpp"
|
||||||
#include "meta_indices/scope_index.hpp"
|
#include "meta_indices/scope_index.hpp"
|
||||||
#include "meta_indices/variable_index.hpp"
|
#include "meta_indices/variable_index.hpp"
|
||||||
|
|
||||||
|
|||||||
@@ -193,6 +193,7 @@ namespace meta_hpp
|
|||||||
class function_index;
|
class function_index;
|
||||||
class member_index;
|
class member_index;
|
||||||
class method_index;
|
class method_index;
|
||||||
|
class parameter_index;
|
||||||
class scope_index;
|
class scope_index;
|
||||||
class variable_index;
|
class variable_index;
|
||||||
|
|
||||||
|
|||||||
@@ -115,6 +115,24 @@ namespace meta_hpp
|
|||||||
std::string name_;
|
std::string name_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class parameter_index final {
|
||||||
|
public:
|
||||||
|
parameter_index() = delete;
|
||||||
|
[[nodiscard]] const any_type& get_type() const noexcept;
|
||||||
|
[[nodiscard]] const std::string& get_name() const noexcept;
|
||||||
|
private:
|
||||||
|
friend detail::parameter_state;
|
||||||
|
template < typename Parameter >
|
||||||
|
[[nodiscard]] static parameter_index make(std::string name);
|
||||||
|
private:
|
||||||
|
explicit parameter_index(any_type type, std::string name);
|
||||||
|
friend bool operator<(const parameter_index& l, const parameter_index& r) noexcept;
|
||||||
|
friend bool operator==(const parameter_index& l, const parameter_index& r) noexcept;
|
||||||
|
private:
|
||||||
|
any_type type_;
|
||||||
|
std::string name_;
|
||||||
|
};
|
||||||
|
|
||||||
class scope_index final {
|
class scope_index final {
|
||||||
public:
|
public:
|
||||||
scope_index() = delete;
|
scope_index() = delete;
|
||||||
|
|||||||
41
headers/meta.hpp/meta_indices/parameter_index.hpp
Normal file
41
headers/meta.hpp/meta_indices/parameter_index.hpp
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* 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_base.hpp"
|
||||||
|
#include "../meta_indices.hpp"
|
||||||
|
#include "../meta_types.hpp"
|
||||||
|
|
||||||
|
#include "../meta_detail/type_registry.hpp"
|
||||||
|
|
||||||
|
namespace meta_hpp
|
||||||
|
{
|
||||||
|
inline parameter_index::parameter_index(any_type type, std::string name)
|
||||||
|
: type_{std::move(type)}
|
||||||
|
, name_{std::move(name)} {}
|
||||||
|
|
||||||
|
template < typename Parameter >
|
||||||
|
inline parameter_index parameter_index::make(std::string name) {
|
||||||
|
return parameter_index{detail::resolve_type<Parameter>(), std::move(name)};
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const any_type& parameter_index::get_type() const noexcept {
|
||||||
|
return type_;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const std::string& parameter_index::get_name() const noexcept {
|
||||||
|
return name_;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool operator<(const parameter_index& l, const parameter_index& r) noexcept {
|
||||||
|
return l.type_ < r.type_ || (l.type_ == r.type_ && std::less<>{}(l.name_, r.name_));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool operator==(const parameter_index& l, const parameter_index& r) noexcept {
|
||||||
|
return l.type_ == r.type_ && std::equal_to<>{}(l.name_, r.name_);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user