parameter_index

This commit is contained in:
BlackMATov
2022-02-07 23:58:32 +07:00
parent f1d9b11b1b
commit 54526bdd84
4 changed files with 61 additions and 0 deletions

View File

@@ -20,6 +20,7 @@
#include "meta_indices/function_index.hpp"
#include "meta_indices/member_index.hpp"
#include "meta_indices/method_index.hpp"
#include "meta_indices/parameter_index.hpp"
#include "meta_indices/scope_index.hpp"
#include "meta_indices/variable_index.hpp"

View File

@@ -193,6 +193,7 @@ namespace meta_hpp
class function_index;
class member_index;
class method_index;
class parameter_index;
class scope_index;
class variable_index;

View File

@@ -115,6 +115,24 @@ namespace meta_hpp
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 {
public:
scope_index() = delete;

View 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_);
}
}