Sfoglia il codice sorgente

y_combinator: constexpr-ness all the way (see #883)

Michele Caini 3 anni fa
parent
commit
3a92a93604
1 ha cambiato i file con 3 aggiunte e 3 eliminazioni
  1. 3 3
      src/entt/core/utility.hpp

+ 3 - 3
src/entt/core/utility.hpp

@@ -72,7 +72,7 @@ struct y_combinator {
      * @brief Constructs a y-combinator from a given function.
      * @brief Constructs a y-combinator from a given function.
      * @param recursive A potentially recursive function.
      * @param recursive A potentially recursive function.
      */
      */
-    y_combinator(Func recursive)
+    constexpr y_combinator(Func recursive)
         : func{std::move(recursive)} {}
         : func{std::move(recursive)} {}
 
 
     /**
     /**
@@ -82,13 +82,13 @@ struct y_combinator {
      * @return Return value of the underlying function, if any.
      * @return Return value of the underlying function, if any.
      */
      */
     template<class... Args>
     template<class... Args>
-    decltype(auto) operator()(Args &&...args) const {
+    constexpr decltype(auto) operator()(Args &&...args) const {
         return func(*this, std::forward<Args>(args)...);
         return func(*this, std::forward<Args>(args)...);
     }
     }
 
 
     /*! @copydoc operator()() */
     /*! @copydoc operator()() */
     template<class... Args>
     template<class... Args>
-    decltype(auto) operator()(Args &&...args) {
+    constexpr decltype(auto) operator()(Args &&...args) {
         return func(*this, std::forward<Args>(args)...);
         return func(*this, std::forward<Args>(args)...);
     }
     }