Преглед на файлове

sigh mixin: const correctness for the return type of ::emplace

Michele Caini преди 1 година
родител
ревизия
331a8257be
променени са 1 файла, в които са добавени 4 реда и са изтрити 3 реда
  1. 4 3
      src/entt/entity/mixin.hpp

+ 4 - 3
src/entt/entity/mixin.hpp

@@ -300,7 +300,7 @@ public:
      * (for example, components vs entities).<br/>
      * Refer to the specific documentation for more details.
      *
-     * @return A return value as returned by the underlying storage.
+     * @return Whatever the underlying storage returns.
      */
     auto emplace() {
         const auto entt = underlying_type::emplace();
@@ -318,10 +318,11 @@ public:
      * @tparam Args Types of arguments to forward to the underlying storage.
      * @param hint A valid identifier.
      * @param args Parameters to forward to the underlying storage.
-     * @return A return value as returned by the underlying storage.
+     * @return Whatever the underlying storage returns.
      */
     template<typename... Args>
-    decltype(auto) emplace(const entity_type hint, Args &&...args) {
+    std::conditional_t<std::is_same_v<typename underlying_type::element_type, entity_type>, entity_type, decltype(std::declval<underlying_type>().get({}))>
+    emplace(const entity_type hint, Args &&...args) {
         if constexpr(std::is_same_v<typename underlying_type::element_type, entity_type>) {
             const auto entt = underlying_type::emplace(hint, std::forward<Args>(args)...);
             construction.publish(owner_or_assert(), entt);