Просмотр исходного кода

meta: as_alias[_t] -> as_ref[_t] (see #479)

Michele Caini 5 лет назад
Родитель
Сommit
0adee56d76
3 измененных файлов с 19 добавлено и 10 удалено
  1. 5 5
      docs/md/meta.md
  2. 2 2
      src/entt/meta/factory.hpp
  3. 12 3
      src/entt/meta/policy.hpp

+ 5 - 5
docs/md/meta.md

@@ -440,10 +440,10 @@ There are a few alternatives available at the moment:
   entt::meta<my_type>().func<&my_type::member_function, entt::as_void_t>("member"_hs);
   entt::meta<my_type>().func<&my_type::member_function, entt::as_void_t>("member"_hs);
   ```
   ```
 
 
-* The _as-alias_ policy, associated with the type `entt::as_alias_t`.<br/>
-  It allows to build wrappers that act as aliases for the objects that generated
-  them. Modifying the object contained in the wrapper for which the _aliasing_
-  was requested will make it possible to directly modify the instance used to
+* The _as-ref_ policy, associated with the type `entt::as_ref_t`.<br/>
+  It allows to build wrappers that act as references to unmanaged objects.
+  Modifying the object contained in the wrapper for which the _reference_ was
+  requested will make it possible to directly modify the instance used to
   initialize the wrapper itself.<br/>
   initialize the wrapper itself.<br/>
   This policy works with constructors (for example, when objects are taken from
   This policy works with constructors (for example, when objects are taken from
   an external container rather than created on demand), data members and
   an external container rather than created on demand), data members and
@@ -452,7 +452,7 @@ There are a few alternatives available at the moment:
   As an example of use:
   As an example of use:
 
 
   ```cpp
   ```cpp
-  entt::meta<my_type>().data<&my_type::data_member, entt::as_alias_t>("member"_hs);
+  entt::meta<my_type>().data<&my_type::data_member, entt::as_ref_t>("member"_hs);
   ```
   ```
 
 
 Some uses are rather trivial, but it's useful to note that there are some less
 Some uses are rather trivial, but it's useful to note that there are some less

+ 2 - 2
src/entt/meta/factory.hpp

@@ -159,7 +159,7 @@ meta_any getter([[maybe_unused]] meta_any instance, [[maybe_unused]] meta_any in
     auto dispatch = [](auto &&value) {
     auto dispatch = [](auto &&value) {
         if constexpr(std::is_same_v<Policy, as_void_t>) {
         if constexpr(std::is_same_v<Policy, as_void_t>) {
             return meta_any{std::in_place_type<void>, std::forward<decltype(value)>(value)};
             return meta_any{std::in_place_type<void>, std::forward<decltype(value)>(value)};
-        } else if constexpr(std::is_same_v<Policy, as_alias_t>) {
+        } else if constexpr(std::is_same_v<Policy, as_ref_t>) {
             return meta_any{std::ref(std::forward<decltype(value)>(value))};
             return meta_any{std::ref(std::forward<decltype(value)>(value))};
         } else {
         } else {
             static_assert(std::is_same_v<Policy, as_is_t>);
             static_assert(std::is_same_v<Policy, as_is_t>);
@@ -203,7 +203,7 @@ meta_any invoke([[maybe_unused]] meta_any instance, meta_any *args, std::index_s
         if constexpr(std::is_void_v<typename helper_type::return_type> || std::is_same_v<Policy, as_void_t>) {
         if constexpr(std::is_void_v<typename helper_type::return_type> || std::is_same_v<Policy, as_void_t>) {
             std::invoke(Candidate, *params...);
             std::invoke(Candidate, *params...);
             return meta_any{std::in_place_type<void>};
             return meta_any{std::in_place_type<void>};
-        } else if constexpr(std::is_same_v<Policy, as_alias_t>) {
+        } else if constexpr(std::is_same_v<Policy, as_ref_t>) {
             return meta_any{std::ref(std::invoke(Candidate, *params...))};
             return meta_any{std::ref(std::invoke(Candidate, *params...))};
         } else {
         } else {
             static_assert(std::is_same_v<Policy, as_is_t>);
             static_assert(std::is_same_v<Policy, as_is_t>);

+ 12 - 3
src/entt/meta/policy.hpp

@@ -5,12 +5,21 @@
 namespace entt {
 namespace entt {
 
 
 
 
-/*! @brief Empty class type used to request the _as alias_ policy. */
-struct as_alias_t {};
+/*! @brief Empty class type used to request the _as ref_ policy. */
+struct as_ref_t {};
 
 
 
 
 /*! @brief Disambiguation tag. */
 /*! @brief Disambiguation tag. */
-inline constexpr as_alias_t as_alias;
+inline constexpr as_ref_t as_ref;
+
+
+/*! @copydoc as_ref_t */
+using as_alias_t [[deprecated("use as_ref_t instead")]] = as_ref_t;
+
+
+/*! @copydoc as_ref */
+[[deprecated("use as_ref instead")]]
+inline constexpr as_ref_t as_alias;
 
 
 
 
 /*! @brief Empty class type used to request the _as-is_ policy. */
 /*! @brief Empty class type used to request the _as-is_ policy. */