From 38e36df7cb4e18f771c19ed6b7a24d2f89099b3d Mon Sep 17 00:00:00 2001 From: Jesse Natalie Date: Sun, 26 Sep 2021 11:03:56 -0700 Subject: [PATCH] clover: std::result_of is deprecated in c++17 and removed in c++20 Reviewed-by: Karol Herbst Reviewed-by: Francisco Jerez Part-of: --- src/gallium/frontends/clover/meson.build | 1 + src/gallium/frontends/clover/util/adaptor.hpp | 5 ++- src/gallium/frontends/clover/util/compat.hpp | 43 +++++++++++++++++++ 3 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 src/gallium/frontends/clover/util/compat.hpp diff --git a/src/gallium/frontends/clover/meson.build b/src/gallium/frontends/clover/meson.build index b6a231f9790..e6aed0fcb51 100644 --- a/src/gallium/frontends/clover/meson.build +++ b/src/gallium/frontends/clover/meson.build @@ -148,6 +148,7 @@ clover_files = files( 'util/adaptor.hpp', 'util/algebra.hpp', 'util/algorithm.hpp', + 'util/compat.hpp', 'util/factor.hpp', 'util/functional.hpp', 'util/lazy.hpp', diff --git a/src/gallium/frontends/clover/util/adaptor.hpp b/src/gallium/frontends/clover/util/adaptor.hpp index e9035968573..08601fc416b 100644 --- a/src/gallium/frontends/clover/util/adaptor.hpp +++ b/src/gallium/frontends/clover/util/adaptor.hpp @@ -25,6 +25,7 @@ #include +#include "util/compat.hpp" #include "util/tuple.hpp" #include "util/pointer.hpp" #include "util/functional.hpp" @@ -43,8 +44,8 @@ namespace clover { class iterator_adaptor { public: typedef std::forward_iterator_tag iterator_category; - typedef typename std::result_of< - F(typename std::iterator_traits::reference...) + typedef typename invoke_result< + F, typename std::iterator_traits::reference... >::type reference; typedef typename std::remove_reference::type value_type; typedef pseudo_ptr pointer; diff --git a/src/gallium/frontends/clover/util/compat.hpp b/src/gallium/frontends/clover/util/compat.hpp new file mode 100644 index 00000000000..dd8db8d2c51 --- /dev/null +++ b/src/gallium/frontends/clover/util/compat.hpp @@ -0,0 +1,43 @@ +// +// Copyright © Microsoft Corporation +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR +// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +#ifndef CLOVER_UTIL_COMPAT_HPP +#define CLOVER_UTIL_COMPAT_HPP + +#include + +namespace clover { + template + struct invoke_result { +#if __cplusplus >= 201703L + typedef typename std::invoke_result< + F, Args... + >::type type; +#else + typedef typename std::result_of< + F(Args...) + >::type type; +#endif + }; +} + +#endif