diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2022-11-19 15:18:02 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-11-19 15:18:02 +0100 |
commit | 67760d797c7dac09077e59a87fa3c27a610a5fc4 (patch) | |
tree | 62d2c53bf5a5f3935bbfc059ba49dbe5b1c6e29d /entity | |
parent | 17ee71b537bf65923acc021a1ed382ab76df9f98 (diff) |
entity: make `constantly` more generic
Diffstat (limited to 'entity')
-rw-r--r-- | entity/metadata.hpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/entity/metadata.hpp b/entity/metadata.hpp index 60e9c458..c9b9a1d5 100644 --- a/entity/metadata.hpp +++ b/entity/metadata.hpp @@ -70,18 +70,17 @@ struct find_reader<Obj, Type, Default, I, F, Fs...> { using type = F; static con namespace floormat::entities { -template<typename Obj, auto constant> -constexpr auto constantly = [](const Obj&) constexpr { return constant; }; +template<typename... Ts> constexpr auto constantly(const auto& x) noexcept { return [x](const Ts&...) constexpr { return x; }; } template<typename Obj, typename Type> struct entity_field_base {}; template<typename Obj, typename Type, FieldReader<Obj, Type> R, FieldWriter<Obj, Type> W, typename... Ts> struct entity_field : entity_field_base<Obj, Type> { private: - static constexpr auto default_predicate = constantly<Obj, field_status::enabled>; - static constexpr auto default_c_range = constantly<Obj, constraints::range<Type>{}>; - static constexpr auto default_c_length = constantly<Obj, constraints::length{std::size_t(-1)}>; - static constexpr auto default_c_group = [](const Obj&) constexpr { return StringView{}; }; + static constexpr auto default_predicate = constantly<Obj>(field_status::enabled); + static constexpr auto default_c_range = constantly<Obj>(constraints::range<Type>{}); + static constexpr auto default_c_length = constantly<Obj>(constraints::length{std::size_t(-1)}); + static constexpr auto default_c_group = constantly<Obj>(StringView{}); using default_predicate_t = std::decay_t<decltype(default_predicate)>; using default_c_range_t = std::decay_t<decltype(default_c_range)>; using default_c_length_t = std::decay_t<decltype(default_c_length)>; |