Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[sonar] Replace the use of "::type" with the "_t" version of type traits.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 13 Jan 2021 09:10:15 +0000 (10:10 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 13 Jan 2021 14:58:37 +0000 (15:58 +0100)
include/simgrid/kernel/future.hpp
include/simgrid/s4u/Actor.hpp
include/simgrid/simix.hpp
include/xbt/config.hpp
include/xbt/functional.hpp
src/instr/instr_paje_events.hpp
src/mc/remote/Channel.hpp
src/mc/remote/RemotePtr.hpp
src/simix/popping_private.hpp

index 7940230..b0be4b1 100644 (file)
@@ -358,19 +358,16 @@ public:
    * @exception std::future_error no state is associated with the future
    */
   template <class F>
-  auto then(F continuation) -> typename std::enable_if<not is_future<decltype(continuation(std::move(*this)))>::value,
-                                                       Future<decltype(continuation(std::move(*this)))>>::type
+  auto then(F continuation) -> typename std::enable_if_t<not is_future<decltype(continuation(std::move(*this)))>::value,
+                                                         Future<decltype(continuation(std::move(*this)))>>
   {
     return this->then_no_unwrap(std::move(continuation));
   }
 
   /** Attach a continuation to this future (future chaining) */
-  template<class F>
-  auto then(F continuation)
-  -> typename std::enable_if<
-       is_future<decltype(continuation(std::move(*this)))>::value,
-       decltype(continuation(std::move(*this)))
-     >::type
+  template <class F>
+  auto then(F continuation) -> typename std::enable_if_t<is_future<decltype(continuation(std::move(*this)))>::value,
+                                                         decltype(continuation(std::move(*this)))>
   {
     return unwrap_future(this->then_no_unwrap(std::move(continuation)));
   }
index 1e79607..1aa3835 100644 (file)
@@ -120,7 +120,7 @@ public:
    * Note that the arguments will be copied, so move-only parameters are forbidden */
   template <class F, class... Args,
             // This constructor is enabled only if the call code(args...) is valid:
-            typename = typename std::result_of<F(Args...)>::type>
+            typename = typename std::result_of_t<F(Args...)>>
   static ActorPtr create(const std::string& name, s4u::Host* host, F code, Args... args)
   {
     return create(name, host, std::bind(std::move(code), std::move(args)...));
index 203d452..a75c594 100644 (file)
@@ -43,7 +43,7 @@ namespace actor {
  * you may need to wait for that mutex to be unlocked by its current owner.
  * Potentially blocking simcall must be issued using simcall_blocking(), right below in this file.
  */
-template <class F> typename std::result_of<F()>::type simcall(F&& code, mc::SimcallInspector* t = nullptr)
+template <class F> typename std::result_of_t<F()> simcall(F&& code, mc::SimcallInspector* t = nullptr)
 {
   // If we are in the maestro, we take the fast path and execute the
   // code directly without simcall marshalling/unmarshalling/dispatch:
@@ -53,7 +53,7 @@ template <class F> typename std::result_of<F()>::type simcall(F&& code, mc::Simc
   // If we are in the application, pass the code to the maestro which
   // executes it for us and reports the result. We use a std::future which
   // conveniently handles the success/failure value for us.
-  using R = typename std::result_of<F()>::type;
+  using R = typename std::result_of_t<F()>;
   simgrid::xbt::Result<R> result;
   simcall_run_kernel([&result, &code] { simgrid::xbt::fulfill_promise(result, std::forward<F>(code)); }, t);
   return result.get();
index 25e9cdf..87343a0 100644 (file)
@@ -132,7 +132,7 @@ void bind_flag(T& value, const char* name, std::initializer_list<const char*> al
  */
 // F is a checker, F : T& -> ()
 template <class T, class F>
-typename std::enable_if<std::is_same<void, decltype(std::declval<F>()(std::declval<const T&>()))>::value, void>::type
+typename std::enable_if_t<std::is_same<void, decltype(std::declval<F>()(std::declval<const T&>()))>::value, void>
 bind_flag(T& value, const char* name, const char* description, F callback)
 {
   declare_flag(name, description, value, std::function<void(const T&)>([&value, callback](const T& val) {
@@ -142,7 +142,7 @@ bind_flag(T& value, const char* name, const char* description, F callback)
 }
 
 template <class T, class F>
-typename std::enable_if<std::is_same<void, decltype(std::declval<F>()(std::declval<const T&>()))>::value, void>::type
+typename std::enable_if_t<std::is_same<void, decltype(std::declval<F>()(std::declval<const T&>()))>::value, void>
 bind_flag(T& value, const char* name, std::initializer_list<const char*> aliases, const char* description, F callback)
 {
   bind_flag(value, name, description, std::move(callback));
@@ -150,8 +150,8 @@ bind_flag(T& value, const char* name, std::initializer_list<const char*> aliases
 }
 
 template <class F>
-typename std::enable_if<std::is_same<void, decltype(std::declval<F>()(std::declval<const std::string&>()))>::value,
-                        void>::type
+typename std::enable_if_t<std::is_same<void, decltype(std::declval<F>()(std::declval<const std::string&>()))>::value,
+                          void>
 bind_flag(std::string& value, const char* name, const char* description,
           const std::map<std::string, std::string, std::less<>>& valid_values, F callback)
 {
@@ -173,8 +173,8 @@ bind_flag(std::string& value, const char* name, const char* description,
                }));
 }
 template <class F>
-typename std::enable_if<std::is_same<void, decltype(std::declval<F>()(std::declval<const std::string&>()))>::value,
-                        void>::type
+typename std::enable_if_t<std::is_same<void, decltype(std::declval<F>()(std::declval<const std::string&>()))>::value,
+                          void>
 bind_flag(std::string& value, const char* name, std::initializer_list<const char*> aliases, const char* description,
           const std::map<std::string, std::string, std::less<>>& valid_values, F callback)
 {
@@ -191,7 +191,7 @@ bind_flag(std::string& value, const char* name, std::initializer_list<const char
  */
 // F is a predicate, F : T const& -> bool
 template <class T, class F>
-typename std::enable_if<std::is_same<bool, decltype(std::declval<F>()(std::declval<const T&>()))>::value, void>::type
+typename std::enable_if_t<std::is_same<bool, decltype(std::declval<F>()(std::declval<const T&>()))>::value, void>
 bind_flag(T& value, const char* name, const char* description, F callback)
 {
   declare_flag(name, description, value, std::function<void(const T&)>([&value, callback](const T& val) {
index a9e035a..4f5ca2c 100644 (file)
@@ -77,11 +77,10 @@ constexpr auto apply(F&& f, Tuple&& t, std::index_sequence<I...>)
 template <class F, class Tuple>
 constexpr auto apply(F&& f, Tuple&& t) -> decltype(
     simgrid::xbt::bits::apply(std::forward<F>(f), std::forward<Tuple>(t),
-                              std::make_index_sequence<std::tuple_size<typename std::decay<Tuple>::type>::value>()))
+                              std::make_index_sequence<std::tuple_size<typename std::decay_t<Tuple>>::value>()))
 {
-  return simgrid::xbt::bits::apply(
-      std::forward<F>(f), std::forward<Tuple>(t),
-      std::make_index_sequence<std::tuple_size<typename std::decay<Tuple>::type>::value>());
+  return simgrid::xbt::bits::apply(std::forward<F>(f), std::forward<Tuple>(t),
+                                   std::make_index_sequence<std::tuple_size<typename std::decay_t<Tuple>>::value>());
 }
 
 template<class T> class Task;
@@ -99,8 +98,8 @@ class Task<R(Args...)> {
   struct whatever {};
 
   // Union used for storage:
-  using TaskUnion = typename std::aligned_union<0, void*, std::pair<void (*)(), void*>,
-                                                std::pair<void (whatever::*)(), whatever*>>::type;
+  using TaskUnion =
+      typename std::aligned_union_t<0, void*, std::pair<void (*)(), void*>, std::pair<void (whatever::*)(), whatever*>>;
 
   // Is F suitable for small buffer optimization?
   template<class F>
@@ -169,9 +168,7 @@ public:
   }
 
 private:
-  template<class F>
-  typename std::enable_if<canSBO<F>()>::type
-  init(F code)
+  template <class F> typename std::enable_if_t<canSBO<F>()> init(F code)
   {
     const static TaskVtable vtable {
       // Call:
@@ -201,7 +198,7 @@ private:
     vtable_ = &vtable;
   }
 
-  template <class F> typename std::enable_if<not canSBO<F>()>::type init(F code)
+  template <class F> typename std::enable_if_t<not canSBO<F>()> init(F code)
   {
     const static TaskVtable vtable {
       // Call:
index e356fb2..266f328 100644 (file)
@@ -40,7 +40,7 @@ enum class PajeEventType : unsigned int {
 
 inline std::ostream& operator<<(std::ostream& os, PajeEventType event)
 {
-  return os << static_cast<std::underlying_type<PajeEventType>::type>(event);
+  return os << static_cast<std::underlying_type_t<PajeEventType>>(event);
 }
 
 class PajeEvent {
index 52c1c62..c0ae225 100644 (file)
@@ -41,14 +41,14 @@ public:
     return this->send(&message, sizeof(message));
   }
   /** @brief Send a message; returns 0 on success or errno on failure */
-  template <class M> typename std::enable_if<messageType<M>(), int>::type send(M const& m) const
+  template <class M> typename std::enable_if_t<messageType<M>(), int> send(M const& m) const
   {
     return this->send(&m, sizeof(M));
   }
 
   // Receive
   ssize_t receive(void* message, size_t size, bool block = true) const;
-  template <class M> typename std::enable_if<messageType<M>(), ssize_t>::type receive(M& m) const
+  template <class M> typename std::enable_if_t<messageType<M>(), ssize_t> receive(M& m) const
   {
     return this->receive(&m, sizeof(M));
   }
index 483047f..4211542 100644 (file)
@@ -27,7 +27,7 @@ namespace mc {
  */
 template <class T> class Remote {
 private:
-  typename std::aligned_storage<sizeof(T), alignof(T)>::type buffer;
+  typename std::aligned_storage_t<sizeof(T), alignof(T)> buffer;
 
 public:
   Remote() = default;
index 043c452..28b1f12 100644 (file)
@@ -169,11 +169,11 @@ template <class T> inline void marshal(u_smx_scalar& simcall, T const& value)
 {
   return marshal(type<T>(), simcall, value);
 }
-template <class T> inline typename std::remove_reference<T>::type unmarshal(u_smx_scalar& simcall)
+template <class T> inline typename std::remove_reference_t<T> unmarshal(u_smx_scalar& simcall)
 {
   return unmarshal(type<T>(), simcall);
 }
-template <class T> inline typename std::remove_reference<T>::type unmarshal_raw(u_smx_scalar& simcall)
+template <class T> inline typename std::remove_reference_t<T> unmarshal_raw(u_smx_scalar& simcall)
 {
   return unmarshal(type<T>(), simcall);
 }