gdbsupport: use result_of_t instead of result_of in parallel-for.h
authorSimon Marchi <simon.marchi@efficios.com>
Tue, 12 Apr 2022 16:30:08 +0000 (12:30 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Tue, 12 Apr 2022 18:09:49 +0000 (14:09 -0400)
When building with -std=c++11, I get:

In file included from /home/smarchi/src/binutils-gdb/gdb/unittests/parallel-for-selftests.c:22:                                                                             /home/smarchi/src/binutils-gdb/gdb/../gdbsupport/parallel-for.h:134:10: error: â€˜result_of_t’ is not a member of â€˜std’; did you mean â€˜result_of’?
  134 |     std::result_of_t<RangeFunction (RandomIt, RandomIt)>
      |          ^~~~~~~~~~~
      |          result_of

This is because result_of_t has been introduced in C++14.  Use the
equivalent result_of<...>::type instead.

result_of and result_of_t have been removed in C++20 though, so I think
we'll need some patches eventually to make the code use invoke_result
instead, depending on the C++ version.

Change-Id: I4817f361c0ebcdd4b32976898fc368bb302b61b9

gdbsupport/parallel-for.h

index 44303abb71602a1b18b34a165836a44b7e830e99..713ec660306e8fb2dbd8d95b2db1c88d0cb9a78d 100644 (file)
@@ -131,13 +131,13 @@ private:
 
 template<class RandomIt, class RangeFunction>
 typename gdb::detail::par_for_accumulator<
-    std::result_of_t<RangeFunction (RandomIt, RandomIt)>
+    typename std::result_of<RangeFunction (RandomIt, RandomIt)>::type
   >::result_type
 parallel_for_each (unsigned n, RandomIt first, RandomIt last,
                   RangeFunction callback)
 {
-  typedef typename std::result_of_t<RangeFunction (RandomIt, RandomIt)>
-    result_type;
+  using result_type
+    = typename std::result_of<RangeFunction (RandomIt, RandomIt)>::type;
 
   size_t n_threads = thread_pool::g_thread_pool->thread_count ();
   size_t n_elements = last - first;