//////////////////////////////////////////////////////////////////////////////// /// DISCLAIMER /// /// Copyright 2018 ArangoDB GmbH, Cologne, Germany /// /// 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. /// /// Copyright holder is ArangoDB GmbH, Cologne, Germany /// /// @author Simon Grätzer //////////////////////////////////////////////////////////////////////////////// #ifndef ARANGOD_FUTURES_BACKPORTS_H #define ARANGOD_FUTURES_BACKPORTS_H 1 #if __cplusplus >= 201703L #include #include #endif #include namespace arangodb { namespace futures { /// Backports from C++17 of: /// std::in_place_t /// std::in_place /// std::is_invocable /// std::is_invocable_r /// std::invoke #if __cplusplus < 201703L struct in_place_tag {}; using in_place_t = in_place_tag (&)(in_place_tag); inline in_place_tag in_place(in_place_tag = {}) { return {}; } template struct is_invocable : std::is_constructible, std::reference_wrapper::type>> { }; template struct is_invocable_r : std::is_constructible, std::reference_wrapper::type>> { }; // mimic: std::invoke, C++17 template constexpr auto invoke(F&& f, Args&&... args) noexcept( noexcept(static_cast(f)(static_cast(args)...))) -> decltype(static_cast(f)(static_cast(args)...)) { return static_cast(f)(static_cast(args)...); } template constexpr auto invoke(M(C::*d), Args&&... args) -> decltype(std::mem_fn(d)(static_cast(args)...)) { return std::mem_fn(d)(static_cast(args)...); } #else using std::invoke; using in_place_t = std::in_place_t; inline constexpr in_place_t in_place{}; template using is_invocable_r = std::is_invocable_r; template using is_invocable = std::is_invocable; #endif } // namespace futures } // namespace arangodb #endif