diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2023-02-21 07:37:55 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2023-02-21 07:37:55 +0100 |
commit | 1cc674eda2d3002891f8fc5d91e4771c9de0eb1a (patch) | |
tree | 0b9a6d2441c9e9d95fe37e296834412608294437 /entity | |
parent | 12c36a35cf43d3453a5745e4464de531674e8e65 (diff) |
entity: check field name
Diffstat (limited to 'entity')
-rw-r--r-- | entity/accessor.hpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/entity/accessor.hpp b/entity/accessor.hpp index 9836b55f..3b979a16 100644 --- a/entity/accessor.hpp +++ b/entity/accessor.hpp @@ -62,10 +62,13 @@ struct erased_accessor final { {} template<typename T, typename FieldType> - static constexpr bool check_name_static(); + [[nodiscard]] static constexpr bool check_name_static(); template<typename T, typename FieldType> - constexpr bool check_name() const noexcept; + [[nodiscard]] constexpr bool check_name() const noexcept; + + template<typename FieldType> + [[nodiscard]] constexpr bool check_field_name() const noexcept; template<typename Obj> constexpr void do_asserts() const; @@ -109,6 +112,13 @@ constexpr bool erased_accessor::check_name() const noexcept obj == object_type && field == field_type; } +template<typename FieldType> +constexpr bool erased_accessor::check_field_name() const noexcept +{ + constexpr auto name = name_of<FieldType>; + return field_name == name; +} + template<typename Obj, typename FieldType> constexpr void erased_accessor::assert_name() const noexcept { |