Explorar o código

process: [[nodiscard]] (see #501)

Michele Caini %!s(int64=5) %!d(string=hai) anos
pai
achega
57a5736942
Modificáronse 2 ficheiros con 12 adicións e 12 borrados
  1. 9 9
      src/entt/process/process.hpp
  2. 3 3
      src/entt/process/scheduler.hpp

+ 9 - 9
src/entt/process/process.hpp

@@ -84,31 +84,31 @@ class process {
 
 
     template<typename Target = Derived>
     template<typename Target = Derived>
     auto next(integral_constant<state::UNINITIALIZED>)
     auto next(integral_constant<state::UNINITIALIZED>)
-    -> decltype(std::declval<Target>().init()) {
+    -> decltype(std::declval<Target>().init(), void()) {
         static_cast<Target *>(this)->init();
         static_cast<Target *>(this)->init();
     }
     }
 
 
     template<typename Target = Derived>
     template<typename Target = Derived>
     auto next(integral_constant<state::RUNNING>, Delta delta, void *data)
     auto next(integral_constant<state::RUNNING>, Delta delta, void *data)
-    -> decltype(std::declval<Target>().update(delta, data)) {
+    -> decltype(std::declval<Target>().update(delta, data), void()) {
         static_cast<Target *>(this)->update(delta, data);
         static_cast<Target *>(this)->update(delta, data);
     }
     }
 
 
     template<typename Target = Derived>
     template<typename Target = Derived>
     auto next(integral_constant<state::SUCCEEDED>)
     auto next(integral_constant<state::SUCCEEDED>)
-    -> decltype(std::declval<Target>().succeeded()) {
+    -> decltype(std::declval<Target>().succeeded(), void()) {
         static_cast<Target *>(this)->succeeded();
         static_cast<Target *>(this)->succeeded();
     }
     }
 
 
     template<typename Target = Derived>
     template<typename Target = Derived>
     auto next(integral_constant<state::FAILED>)
     auto next(integral_constant<state::FAILED>)
-    -> decltype(std::declval<Target>().failed()) {
+    -> decltype(std::declval<Target>().failed(), void()) {
         static_cast<Target *>(this)->failed();
         static_cast<Target *>(this)->failed();
     }
     }
 
 
     template<typename Target = Derived>
     template<typename Target = Derived>
     auto next(integral_constant<state::ABORTED>)
     auto next(integral_constant<state::ABORTED>)
-    -> decltype(std::declval<Target>().aborted()) {
+    -> decltype(std::declval<Target>().aborted(), void()) {
         static_cast<Target *>(this)->aborted();
         static_cast<Target *>(this)->aborted();
     }
     }
 
 
@@ -194,7 +194,7 @@ public:
      * @brief Returns true if a process is either running or paused.
      * @brief Returns true if a process is either running or paused.
      * @return True if the process is still alive, false otherwise.
      * @return True if the process is still alive, false otherwise.
      */
      */
-    bool alive() const ENTT_NOEXCEPT {
+    [[nodiscard]] bool alive() const ENTT_NOEXCEPT {
         return current == state::RUNNING || current == state::PAUSED;
         return current == state::RUNNING || current == state::PAUSED;
     }
     }
 
 
@@ -202,7 +202,7 @@ public:
      * @brief Returns true if a process is already terminated.
      * @brief Returns true if a process is already terminated.
      * @return True if the process is terminated, false otherwise.
      * @return True if the process is terminated, false otherwise.
      */
      */
-    bool dead() const ENTT_NOEXCEPT {
+    [[nodiscard]] bool dead() const ENTT_NOEXCEPT {
         return current == state::FINISHED;
         return current == state::FINISHED;
     }
     }
 
 
@@ -210,7 +210,7 @@ public:
      * @brief Returns true if a process is currently paused.
      * @brief Returns true if a process is currently paused.
      * @return True if the process is paused, false otherwise.
      * @return True if the process is paused, false otherwise.
      */
      */
-    bool paused() const ENTT_NOEXCEPT {
+    [[nodiscard]] bool paused() const ENTT_NOEXCEPT {
         return current == state::PAUSED;
         return current == state::PAUSED;
     }
     }
 
 
@@ -218,7 +218,7 @@ public:
      * @brief Returns true if a process terminated with errors.
      * @brief Returns true if a process terminated with errors.
      * @return True if the process terminated with errors, false otherwise.
      * @return True if the process terminated with errors, false otherwise.
      */
      */
-    bool rejected() const ENTT_NOEXCEPT {
+    [[nodiscard]] bool rejected() const ENTT_NOEXCEPT {
         return stopped;
         return stopped;
     }
     }
 
 

+ 3 - 3
src/entt/process/scheduler.hpp

@@ -80,7 +80,7 @@ class scheduler {
     };
     };
 
 
     template<typename Proc>
     template<typename Proc>
-    static bool update(process_handler &handler, const Delta delta, void *data) {
+    [[nodiscard]] static bool update(process_handler &handler, const Delta delta, void *data) {
         auto *process = static_cast<Proc *>(handler.instance.get());
         auto *process = static_cast<Proc *>(handler.instance.get());
         process->tick(delta, data);
         process->tick(delta, data);
 
 
@@ -126,7 +126,7 @@ public:
      * @brief Number of processes currently scheduled.
      * @brief Number of processes currently scheduled.
      * @return Number of processes currently scheduled.
      * @return Number of processes currently scheduled.
      */
      */
-    size_type size() const ENTT_NOEXCEPT {
+    [[nodiscard]] size_type size() const ENTT_NOEXCEPT {
         return handlers.size();
         return handlers.size();
     }
     }
 
 
@@ -134,7 +134,7 @@ public:
      * @brief Returns true if at least a process is currently scheduled.
      * @brief Returns true if at least a process is currently scheduled.
      * @return True if there are scheduled processes, false otherwise.
      * @return True if there are scheduled processes, false otherwise.
      */
      */
-    bool empty() const ENTT_NOEXCEPT {
+    [[nodiscard]] bool empty() const ENTT_NOEXCEPT {
         return handlers.empty();
         return handlers.empty();
     }
     }