From 626e7c1f76732e83dde3a1ee506d62b692dbd3fb Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 22 May 2019 16:28:45 +0200 Subject: [PATCH] Workaround MSVC 16.1 bugs. --- Telegram/SourceFiles/ui/effects/animations.h | 120 +++++++++++-------- Telegram/gyp/settings_win.gypi | 2 +- 2 files changed, 71 insertions(+), 51 deletions(-) diff --git a/Telegram/SourceFiles/ui/effects/animations.h b/Telegram/SourceFiles/ui/effects/animations.h index c5dee8b6d..b49a586d2 100644 --- a/Telegram/SourceFiles/ui/effects/animations.h +++ b/Telegram/SourceFiles/ui/effects/animations.h @@ -171,35 +171,45 @@ private: }; +template +Fn Basic__PrepareCrlTime(Callback &&callback) { + using Return = decltype(callback(crl::time(0))); + if constexpr (std::is_convertible_v) { + return std::forward(callback); + } else if constexpr (std::is_same_v) { + return [callback = std::forward(callback)]( + crl::time time) { + callback(time); + return true; + }; + } else { + static_assert(false_t(callback), "Expected void or bool."); + } +} + +template +Fn Basic__PreparePlain(Callback &&callback) { + using Return = decltype(callback()); + if constexpr (std::is_convertible_v) { + return [callback = std::forward(callback)](crl::time) { + return callback(); + }; + } else if constexpr (std::is_same_v) { + return [callback = std::forward(callback)](crl::time) { + callback(); + return true; + }; + } else { + static_assert(false_t(callback), "Expected void or bool."); + } +} + template inline Fn Basic::Prepare(Callback &&callback) { if constexpr (rpl::details::is_callable_plain_v) { - using Return = decltype(callback(crl::time(0))); - if constexpr (std::is_convertible_v) { - return std::forward(callback); - } else if constexpr (std::is_same_v) { - return [callback = std::forward(callback)]( - crl::time time) { - callback(time); - return true; - }; - } else { - static_assert(false_t(callback), "Expected void or bool."); - } + return Basic__PrepareCrlTime(std::forward(callback)); } else if constexpr (rpl::details::is_callable_plain_v) { - using Return = decltype(callback()); - if constexpr (std::is_convertible_v) { - return [callback = std::forward(callback)](crl::time) { - return callback(); - }; - } else if constexpr (std::is_same_v) { - return [callback = std::forward(callback)](crl::time) { - callback(); - return true; - }; - } else { - static_assert(false_t(callback), "Expected void or bool."); - } + return Basic__PreparePlain(std::forward(callback)); } else { static_assert(false_t(callback), "Expected crl::time or no args."); } @@ -232,35 +242,45 @@ inline Basic::~Basic() { stop(); } +template +decltype(auto) Simple__PrepareFloat64(Callback &&callback) { + using Return = decltype(callback(float64(0.))); + if constexpr (std::is_convertible_v) { + return std::forward(callback); + } else if constexpr (std::is_same_v) { + return [callback = std::forward(callback)]( + float64 value) { + callback(value); + return true; + }; + } else { + static_assert(false_t(callback), "Expected void or float64."); + } +} + +template +decltype(auto) Simple__PreparePlain(Callback &&callback) { + using Return = decltype(callback()); + if constexpr (std::is_convertible_v) { + return [callback = std::forward(callback)](float64) { + return callback(); + }; + } else if constexpr (std::is_same_v) { + return [callback = std::forward(callback)](float64) { + callback(); + return true; + }; + } else { + static_assert(false_t(callback), "Expected void or bool."); + } +} + template decltype(auto) Simple::Prepare(Callback &&callback) { if constexpr (rpl::details::is_callable_plain_v) { - using Return = decltype(callback(float64(0.))); - if constexpr (std::is_convertible_v) { - return std::forward(callback); - } else if constexpr (std::is_same_v) { - return [callback = std::forward(callback)]( - float64 value) { - callback(value); - return true; - }; - } else { - static_assert(false_t(callback), "Expected void or float64."); - } + return Simple__PrepareFloat64(std::forward(callback)); } else if constexpr (rpl::details::is_callable_plain_v) { - using Return = decltype(callback()); - if constexpr (std::is_convertible_v) { - return [callback = std::forward(callback)](float64) { - return callback(); - }; - } else if constexpr (std::is_same_v) { - return [callback = std::forward(callback)](float64) { - callback(); - return true; - }; - } else { - static_assert(false_t(callback), "Expected void or bool."); - } + return Simple__PreparePlain(std::forward(callback)); } else { static_assert(false_t(callback), "Expected float64 or no args."); } diff --git a/Telegram/gyp/settings_win.gypi b/Telegram/gyp/settings_win.gypi index cab5f8d40..86b0925ed 100644 --- a/Telegram/gyp/settings_win.gypi +++ b/Telegram/gyp/settings_win.gypi @@ -25,7 +25,7 @@ 'DebugInformationFormat': '3', # Program Database (/Zi) 'WarnAsError': 'true', 'AdditionalOptions': [ - '/std:c++latest', + '/std:c++17', '/permissive-', '/Qspectre', '/MP', # Enable multi process build.