Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ if(cToStr) { // Functor valid?

## Design Highlights

* **Zero-Overhead by Design** – Reflection metadata is registered and resolved lazily. You only pay for what you actually use.
* ***Non-Intrusive & Macro-Free*** – No macros, base classes, or intrusive user-type annotations required.

* **Non-Intrusive & Macro-Free** – No macros, base classes, or intrusive user-type annotations required.
* ***Pay for What You Use*** – Reflection metadata is registered and resolved lazily, so runtime costs are incurred only when reflection is used.

* **Performance** – Reflective calls are on par with `std::function`, and can be even faster when argument and return types are fully specified.
* ***Zero Overhead Invocation*** – When argument and return types are fully specified, reflective calls reduce to a single function-pointer hop.

* ***Performance*** – Reflective calls are on par with `std::function`, and can be even faster when argument and return types are fully specified.

See the [Performance Summary](docs/benchmark_summary.md) for benchmark details.

Expand Down
19 changes: 11 additions & 8 deletions ReflectionTemplateLib/rtl/inc/type_meta.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ namespace rtl
type_meta(const type_meta&) = default;
type_meta& operator=(type_meta&&) = default;
type_meta& operator=(const type_meta&) = default;
const bool operator==(const type_meta& pOther) const;

constexpr const bool is_void() const;
constexpr const bool is_empty() const;
Expand All @@ -42,6 +43,7 @@ namespace rtl
constexpr const traits::uid_t get_normal_args_id() const;
constexpr const traits::uid_t get_strict_args_id() const;


template<class return_t, class ...signature_t>
static type_meta add_function(return_t(*p_fptr)(signature_t...),
traits::uid_t p_record_uid, detail::member p_member_kind);
Expand All @@ -55,14 +57,6 @@ namespace rtl
template<detail::member mem_kind, class record_t, class return_t, class ...signature_t>
static type_meta add_constructor();

const bool operator==(const type_meta& pOther) const {
return (!is_empty() && !pOther.is_empty() &&
get_functor().m_return_id == pOther.get_functor().m_return_id &&
get_functor().m_record_id == pOther.get_functor().m_record_id &&
get_functor().m_strict_args_id == pOther.get_functor().m_strict_args_id &&
get_functor().m_member_kind == pOther.get_functor().m_member_kind);
}

private:

using functor_t = std::optional<std::reference_wrapper<const dispatch::functor>>;
Expand Down Expand Up @@ -119,4 +113,13 @@ namespace rtl
constexpr const std::vector<std::size_t>& type_meta::get_args_id_arr() const {
return m_functor->get().m_args_type_ids;
}

inline const bool type_meta::operator==(const type_meta& pOther) const
{
return (!is_empty() && !pOther.is_empty() &&
get_functor().m_return_id == pOther.get_functor().m_return_id &&
get_functor().m_record_id == pOther.get_functor().m_record_id &&
get_functor().m_strict_args_id == pOther.get_functor().m_strict_args_id &&
get_functor().m_member_kind == pOther.get_functor().m_member_kind);
}
}
Loading