diff --git a/Telegram/CMakeLists.txt b/Telegram/CMakeLists.txt index ad6540f33..5d55028ce 100644 --- a/Telegram/CMakeLists.txt +++ b/Telegram/CMakeLists.txt @@ -714,7 +714,9 @@ target_link_libraries(Kepka Threads::Threads) include(GNUInstallDirs) set_target_properties(Kepka PROPERTIES OUTPUT_NAME "kepka") -install(TARGETS Kepka RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) +install(TARGETS Kepka + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR}) install(FILES "${CMAKE_SOURCE_DIR}/lib/xdg/kepka.desktop" DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/applications diff --git a/Telegram/SourceFiles/backports/is_invocable.h b/Telegram/SourceFiles/backports/is_invocable.h new file mode 100644 index 000000000..a3a693b30 --- /dev/null +++ b/Telegram/SourceFiles/backports/is_invocable.h @@ -0,0 +1,134 @@ +/* Extracted from https://github.com/facebook/folly/blob/master/folly/functional/Invoke.h */ + +/* + * Copyright 2017-present Facebook, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include +#include + +#if __cpp_lib_is_invocable >= 201703 || (_MSC_VER >= 1911 && _MSVC_LANG > 201402) + +namespace backports { + +/* using override */ using std::invoke_result; +/* using override */ using std::invoke_result_t; +/* using override */ using std::is_invocable; +/* using override */ using std::is_invocable_r; +/* using override */ using std::is_invocable_r_v; +/* using override */ using std::is_invocable_v; +/* using override */ using std::is_nothrow_invocable; +/* using override */ using std::is_nothrow_invocable_r; +/* using override */ using std::is_nothrow_invocable_r_v; +/* using override */ using std::is_nothrow_invocable_v; + +} // namespace backports + +#else + +namespace backports { + +namespace invoke_detail { + +template struct Bools { + using valid_type = bool; + static constexpr std::size_t size() { + return sizeof...(Bs); + } +}; + +template struct Negation : std::bool_constant {}; + +// Lighter-weight than Conjunction, but evaluates all sub-conditions eagerly. +template struct StrictConjunction : std::is_same, Bools<(Ts::value || true)...>> {}; + +template +struct StrictDisjunction : Negation, Bools<(Ts::value && false)...>>> {}; + +template +using invoke_result_ = decltype(std::invoke(std::declval(), std::declval()...)); + +template +struct invoke_nothrow_ : std::bool_constant(), std::declval()...))> {}; + +// from: http://en.cppreference.com/w/cpp/types/result_of, CC-BY-SA + +template struct invoke_result {}; + +template struct invoke_result>, F, Args...> { + using type = invoke_result_; +}; + +template struct is_invocable : std::false_type {}; + +template +struct is_invocable>, F, Args...> : std::true_type {}; + +template struct is_invocable_r : std::false_type {}; + +template +struct is_invocable_r>, R, F, Args...> + : std::is_convertible, R> {}; + +template struct is_nothrow_invocable : std::false_type {}; + +template +struct is_nothrow_invocable>, F, Args...> : invoke_nothrow_ {}; + +template struct is_nothrow_invocable_r : std::false_type {}; + +template +struct is_nothrow_invocable_r>, R, F, Args...> + : StrictConjunction, R>, invoke_nothrow_> {}; + +} // namespace invoke_detail + +// mimic: std::invoke_result, C++17 +template struct invoke_result : invoke_detail::invoke_result {}; + +// mimic: std::invoke_result_t, C++17 +template using invoke_result_t = typename invoke_result::type; + +// mimic: std::is_invocable, C++17 +template struct is_invocable : invoke_detail::is_invocable {}; + +// mimic: std::is_invocable_r, C++17 +template +struct is_invocable_r : invoke_detail::is_invocable_r {}; + +// mimic: std::is_nothrow_invocable, C++17 +template +struct is_nothrow_invocable : invoke_detail::is_nothrow_invocable {}; + +// mimic: std::is_nothrow_invocable_r, C++17 +template +struct is_nothrow_invocable_r : invoke_detail::is_nothrow_invocable_r {}; + +template inline constexpr bool is_invocable_v = is_invocable::value; + +template +inline constexpr bool is_invocable_r_v = is_invocable_r::value; + +template +inline constexpr bool is_nothrow_invocable_v = is_nothrow_invocable::value; + +template +inline constexpr bool is_nothrow_invocable_r_v = is_nothrow_invocable_r::value; + +} // namespace backports + +#endif diff --git a/Telegram/SourceFiles/mtproto/rpc_sender.h b/Telegram/SourceFiles/mtproto/rpc_sender.h index b1bc739e0..5859808e0 100644 --- a/Telegram/SourceFiles/mtproto/rpc_sender.h +++ b/Telegram/SourceFiles/mtproto/rpc_sender.h @@ -23,6 +23,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org #include "base/lambda_guard.h" #include "core/basic_types.h" #include "core/utils.h" +#include "backports/is_invocable.h" #include "scheme.h" #include #include @@ -938,14 +939,15 @@ class RPCDoneHandlerImplementationNoReq : public RPCDoneHandlerImplementation -constexpr bool rpcDone_canCallBare_v = std::is_invocable_v; +constexpr bool rpcDone_canCallBare_v = backports::is_invocable_v; template -constexpr bool rpcDone_canCallBareReq_v = std::is_invocable_v; +constexpr bool rpcDone_canCallBareReq_v = + backports::is_invocable_v; -template constexpr bool rpcDone_canCallNo_v = std::is_invocable_v; +template constexpr bool rpcDone_canCallNo_v = backports::is_invocable_v; -template constexpr bool rpcDone_canCallNoReq_v = std::is_invocable_v; +template constexpr bool rpcDone_canCallNoReq_v = backports::is_invocable_v; template struct rpcDone_canCallPlain : std::false_type {}; @@ -1044,14 +1046,14 @@ class RPCFailHandlerImplementationNoReq : public RPCFailHandlerImplementation constexpr bool rpcFail_canCallNo_v = std::is_invocable_v; +template constexpr bool rpcFail_canCallNo_v = backports::is_invocable_v; -template constexpr bool rpcFail_canCallNoReq_v = std::is_invocable_v; +template constexpr bool rpcFail_canCallNoReq_v = backports::is_invocable_v; -template constexpr bool rpcFail_canCallPlain_v = std::is_invocable_v; +template constexpr bool rpcFail_canCallPlain_v = backports::is_invocable_v; template -constexpr bool rpcFail_canCallReq_v = std::is_invocable_v; +constexpr bool rpcFail_canCallReq_v = backports::is_invocable_v; template > RPCFailHandlerPtr rpcFail(Lambda lambda) {