@@ -549,7 +549,8 @@ namespace zenkit {
549549 // / \tparam T The type of instance to check for.
550550 // / \return <tt>true</tt> if the symbol contains an instance of the given type, <tt>false</tt> if not.
551551 template <typename T>
552- ZKAPI std::enable_if_t <std::is_base_of_v<DaedalusInstance, T>, bool > is_instance_of () {
552+ requires std::derived_from<T, DaedalusInstance>
553+ ZKAPI bool is_instance_of () {
553554 return this ->type () == DaedalusDataType::INSTANCE && this ->get_instance () != nullptr &&
554555 this ->get_instance ()->_m_type == &typeid (T);
555556 }
@@ -747,6 +748,10 @@ namespace zenkit {
747748 ZKINT static DaedalusInstruction decode (Read* r);
748749 };
749750
751+ template <typename T>
752+ concept DaedalusValue = std::same_as<T, std::string> || std::same_as<T, float > || std::same_as<T, int32_t > ||
753+ (std::is_enum_v<T> && sizeof (T) == 4 );
754+
750755 // / \brief Represents a compiled daedalus script
751756 class DaedalusScript {
752757 public:
@@ -764,10 +769,8 @@ namespace zenkit {
764769 // / \throws DaedalusInvalidRegistrationDataType If the datatype of \p _member is different than that of the
765770 // / symbol.
766771 template <typename _class, typename _member, int N>
767- std::enable_if_t <std::is_same_v<_member, std::string> || std::is_same_v<_member, float > ||
768- std::is_same_v<_member, std::int32_t > || (std::is_enum_v<_member> && sizeof (_member) == 4 ),
769- void >
770- register_member (std::string_view name, _member (_class::*field)[N]) {
772+ requires DaedalusValue<_member>
773+ void register_member (std::string_view name, _member (_class::*field)[N]) {
771774 auto * type = &typeid (_class);
772775 auto * sym = _check_member<_member, N>(name, type);
773776
@@ -785,10 +788,8 @@ namespace zenkit {
785788 // / \throws DaedalusInvalidRegistrationDataType If the datatype of \p _member is different than that of the
786789 // / symbol.
787790 template <typename _class, typename _member>
788- std::enable_if_t <std::is_same_v<_member, std::string> || std::is_same_v<_member, float > ||
789- std::is_same_v<_member, std::int32_t > || (std::is_enum_v<_member> && sizeof (_member) == 4 ),
790- void >
791- register_member (std::string_view name, _member _class::*field) {
791+ requires DaedalusValue<_member>
792+ void register_member (std::string_view name, _member _class::* field) {
792793 auto * type = &typeid (_class);
793794 auto * sym = _check_member<_member, 1 >(name, type);
794795
@@ -885,8 +886,8 @@ namespace zenkit {
885886 // / \return The symbol associated with that instance or <tt>nullptr</tt> if the symbol is not associated
886887 // / with any instance.
887888 template <typename T>
888- ZKAPI std::enable_if_t <std::is_base_of_v<DaedalusInstance, T>, DaedalusSymbol const * >
889- find_symbol_by_instance (std::shared_ptr<T> const & inst) const {
889+ requires std::derived_from<T, DaedalusInstance >
890+ ZKAPI DaedalusSymbol const * find_symbol_by_instance (std::shared_ptr<T> const & inst) const {
890891 return find_symbol_by_index (inst->_m_symbol_index );
891892 }
892893
@@ -895,8 +896,8 @@ namespace zenkit {
895896 // / \return The symbol associated with that instance or <tt>nullptr</tt> if the symbol is not associated
896897 // / with any instance.
897898 template <typename T>
898- ZKAPI std::enable_if_t <std::is_base_of_v<DaedalusInstance, T>, DaedalusSymbol* >
899- find_symbol_by_instance (std::shared_ptr<T> const & inst) {
899+ requires std::derived_from<T, DaedalusInstance >
900+ ZKAPI DaedalusSymbol* find_symbol_by_instance (std::shared_ptr<T> const & inst) {
900901 return find_symbol_by_index (inst->_m_symbol_index );
901902 }
902903
@@ -933,11 +934,11 @@ namespace zenkit {
933934 }
934935
935936 // check type matches
936- if constexpr (std::is_same_v <std::string, _member>) {
937+ if constexpr (std::same_as <std::string, _member>) {
937938 if (sym->type () != DaedalusDataType::STRING) throw DaedalusInvalidRegistrationDataType {sym, " string" };
938- } else if constexpr (std::is_same_v <float , _member>) {
939+ } else if constexpr (std::same_as <float , _member>) {
939940 if (sym->type () != DaedalusDataType::FLOAT) throw DaedalusInvalidRegistrationDataType {sym, " float" };
940- } else if constexpr (std::is_same_v <int32_t , _member> || std::is_enum_v<_member>) {
941+ } else if constexpr (std::same_as <int32_t , _member> || std::is_enum_v<_member>) {
941942 if (sym->type () != DaedalusDataType::INT && sym->type () != DaedalusDataType::FUNCTION)
942943 throw DaedalusInvalidRegistrationDataType {sym, " int" };
943944 } else {
0 commit comments