From edada81d50549499871369f63a5ac01d652b283e Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Wed, 13 Jan 2021 10:10:15 +0100 Subject: [PATCH] [sonar] Replace the use of "::type" with the "_t" version of type traits. --- include/simgrid/kernel/future.hpp | 13 +++++-------- include/simgrid/s4u/Actor.hpp | 2 +- include/simgrid/simix.hpp | 4 ++-- include/xbt/config.hpp | 14 +++++++------- include/xbt/functional.hpp | 17 +++++++---------- src/instr/instr_paje_events.hpp | 2 +- src/mc/remote/Channel.hpp | 4 ++-- src/mc/remote/RemotePtr.hpp | 2 +- src/simix/popping_private.hpp | 4 ++-- 9 files changed, 28 insertions(+), 34 deletions(-) diff --git a/include/simgrid/kernel/future.hpp b/include/simgrid/kernel/future.hpp index 7940230fd1..b0be4b1e71 100644 --- a/include/simgrid/kernel/future.hpp +++ b/include/simgrid/kernel/future.hpp @@ -358,19 +358,16 @@ public: * @exception std::future_error no state is associated with the future */ template - auto then(F continuation) -> typename std::enable_if::value, - Future>::type + auto then(F continuation) -> typename std::enable_if_t::value, + Future> { return this->then_no_unwrap(std::move(continuation)); } /** Attach a continuation to this future (future chaining) */ - template - auto then(F continuation) - -> typename std::enable_if< - is_future::value, - decltype(continuation(std::move(*this))) - >::type + template + auto then(F continuation) -> typename std::enable_if_t::value, + decltype(continuation(std::move(*this)))> { return unwrap_future(this->then_no_unwrap(std::move(continuation))); } diff --git a/include/simgrid/s4u/Actor.hpp b/include/simgrid/s4u/Actor.hpp index 1e79607f07..1aa38353ac 100644 --- a/include/simgrid/s4u/Actor.hpp +++ b/include/simgrid/s4u/Actor.hpp @@ -120,7 +120,7 @@ public: * Note that the arguments will be copied, so move-only parameters are forbidden */ template ::type> + typename = typename std::result_of_t> 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)...)); diff --git a/include/simgrid/simix.hpp b/include/simgrid/simix.hpp index 203d452305..a75c594261 100644 --- a/include/simgrid/simix.hpp +++ b/include/simgrid/simix.hpp @@ -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 typename std::result_of::type simcall(F&& code, mc::SimcallInspector* t = nullptr) +template typename std::result_of_t 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 typename std::result_of::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::type; + using R = typename std::result_of_t; simgrid::xbt::Result result; simcall_run_kernel([&result, &code] { simgrid::xbt::fulfill_promise(result, std::forward(code)); }, t); return result.get(); diff --git a/include/xbt/config.hpp b/include/xbt/config.hpp index 25e9cdf9e2..87343a0c19 100644 --- a/include/xbt/config.hpp +++ b/include/xbt/config.hpp @@ -132,7 +132,7 @@ void bind_flag(T& value, const char* name, std::initializer_list al */ // F is a checker, F : T& -> () template -typename std::enable_if()(std::declval()))>::value, void>::type +typename std::enable_if_t()(std::declval()))>::value, void> bind_flag(T& value, const char* name, const char* description, F callback) { declare_flag(name, description, value, std::function([&value, callback](const T& val) { @@ -142,7 +142,7 @@ bind_flag(T& value, const char* name, const char* description, F callback) } template -typename std::enable_if()(std::declval()))>::value, void>::type +typename std::enable_if_t()(std::declval()))>::value, void> bind_flag(T& value, const char* name, std::initializer_list 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 aliases } template -typename std::enable_if()(std::declval()))>::value, - void>::type +typename std::enable_if_t()(std::declval()))>::value, + void> bind_flag(std::string& value, const char* name, const char* description, const std::map>& valid_values, F callback) { @@ -173,8 +173,8 @@ bind_flag(std::string& value, const char* name, const char* description, })); } template -typename std::enable_if()(std::declval()))>::value, - void>::type +typename std::enable_if_t()(std::declval()))>::value, + void> bind_flag(std::string& value, const char* name, std::initializer_list aliases, const char* description, const std::map>& valid_values, F callback) { @@ -191,7 +191,7 @@ bind_flag(std::string& value, const char* name, std::initializer_list bool template -typename std::enable_if()(std::declval()))>::value, void>::type +typename std::enable_if_t()(std::declval()))>::value, void> bind_flag(T& value, const char* name, const char* description, F callback) { declare_flag(name, description, value, std::function([&value, callback](const T& val) { diff --git a/include/xbt/functional.hpp b/include/xbt/functional.hpp index a9e035a837..4f5ca2ce32 100644 --- a/include/xbt/functional.hpp +++ b/include/xbt/functional.hpp @@ -77,11 +77,10 @@ constexpr auto apply(F&& f, Tuple&& t, std::index_sequence) template constexpr auto apply(F&& f, Tuple&& t) -> decltype( simgrid::xbt::bits::apply(std::forward(f), std::forward(t), - std::make_index_sequence::type>::value>())) + std::make_index_sequence>::value>())) { - return simgrid::xbt::bits::apply( - std::forward(f), std::forward(t), - std::make_index_sequence::type>::value>()); + return simgrid::xbt::bits::apply(std::forward(f), std::forward(t), + std::make_index_sequence>::value>()); } template class Task; @@ -99,8 +98,8 @@ class Task { struct whatever {}; // Union used for storage: - using TaskUnion = typename std::aligned_union<0, void*, std::pair, - std::pair>::type; + using TaskUnion = + typename std::aligned_union_t<0, void*, std::pair, std::pair>; // Is F suitable for small buffer optimization? template @@ -169,9 +168,7 @@ public: } private: - template - typename std::enable_if()>::type - init(F code) + template typename std::enable_if_t()> init(F code) { const static TaskVtable vtable { // Call: @@ -201,7 +198,7 @@ private: vtable_ = &vtable; } - template typename std::enable_if()>::type init(F code) + template typename std::enable_if_t()> init(F code) { const static TaskVtable vtable { // Call: diff --git a/src/instr/instr_paje_events.hpp b/src/instr/instr_paje_events.hpp index e356fb21c4..266f328676 100644 --- a/src/instr/instr_paje_events.hpp +++ b/src/instr/instr_paje_events.hpp @@ -40,7 +40,7 @@ enum class PajeEventType : unsigned int { inline std::ostream& operator<<(std::ostream& os, PajeEventType event) { - return os << static_cast::type>(event); + return os << static_cast>(event); } class PajeEvent { diff --git a/src/mc/remote/Channel.hpp b/src/mc/remote/Channel.hpp index 52c1c626d4..c0ae225505 100644 --- a/src/mc/remote/Channel.hpp +++ b/src/mc/remote/Channel.hpp @@ -41,14 +41,14 @@ public: return this->send(&message, sizeof(message)); } /** @brief Send a message; returns 0 on success or errno on failure */ - template typename std::enable_if(), int>::type send(M const& m) const + template typename std::enable_if_t(), 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 typename std::enable_if(), ssize_t>::type receive(M& m) const + template typename std::enable_if_t(), ssize_t> receive(M& m) const { return this->receive(&m, sizeof(M)); } diff --git a/src/mc/remote/RemotePtr.hpp b/src/mc/remote/RemotePtr.hpp index 483047fbce..42115420fd 100644 --- a/src/mc/remote/RemotePtr.hpp +++ b/src/mc/remote/RemotePtr.hpp @@ -27,7 +27,7 @@ namespace mc { */ template class Remote { private: - typename std::aligned_storage::type buffer; + typename std::aligned_storage_t buffer; public: Remote() = default; diff --git a/src/simix/popping_private.hpp b/src/simix/popping_private.hpp index 043c452344..28b1f129da 100644 --- a/src/simix/popping_private.hpp +++ b/src/simix/popping_private.hpp @@ -169,11 +169,11 @@ template inline void marshal(u_smx_scalar& simcall, T const& value) { return marshal(type(), simcall, value); } -template inline typename std::remove_reference::type unmarshal(u_smx_scalar& simcall) +template inline typename std::remove_reference_t unmarshal(u_smx_scalar& simcall) { return unmarshal(type(), simcall); } -template inline typename std::remove_reference::type unmarshal_raw(u_smx_scalar& simcall) +template inline typename std::remove_reference_t unmarshal_raw(u_smx_scalar& simcall) { return unmarshal(type(), simcall); } -- 2.20.1