OSDN Git Service

Reactor: Replace ArgI for std::tuple_element
authorBen Clayton <bclayton@google.com>
Wed, 27 Feb 2019 23:58:35 +0000 (23:58 +0000)
committerBen Clayton <headlessclayton@gmail.com>
Sat, 30 Mar 2019 12:06:02 +0000 (12:06 +0000)
C++ now provides this template magic so you don't have to.

Also remove Arg(Function<Return(Arguments...)> &) function that wasn't referenced and wouldn't compile if it were.

Bug: b/126126820
Bug: b/129403963
Change-Id: I939e4f7cb95c32b8e663df7da6211460c5de605f
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/25749
Presubmit-Ready: Ben Clayton <bclayton@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Tested-by: Ben Clayton <headlessclayton@gmail.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
src/Reactor/Reactor.hpp

index 7cf4103..9aea089 100644 (file)
@@ -23,6 +23,7 @@
 #include <cstdio>
 
 #include <string>
+#include <tuple>
 
 #undef Bool // b/127920555
 
@@ -2274,21 +2275,6 @@ namespace rr
        template<class T>
        void Return(RValue<Pointer<T>> ret);
 
-       template<unsigned int index, typename... Arguments>
-       struct ArgI;
-
-       template<typename Arg0, typename... Arguments>
-       struct ArgI<0, Arg0, Arguments...>
-       {
-               typedef Arg0 Type;
-       };
-
-       template<unsigned int index, typename Arg0, typename... Arguments>
-       struct ArgI<index, Arg0, Arguments...>
-       {
-               typedef typename ArgI<index - 1, Arguments...>::Type Type;
-       };
-
        // Generic template, leave undefined!
        template<typename FunctionType>
        class Function;
@@ -2303,10 +2289,10 @@ namespace rr
                virtual ~Function();
 
                template<int index>
-               Argument<typename ArgI<index, Arguments...>::Type> Arg() const
+               Argument<typename std::tuple_element<index, std::tuple<Arguments...>>::type> Arg() const
                {
                        Value *arg = Nucleus::getArgument(index);
-                       return Argument<typename ArgI<index, Arguments...>::Type>(arg);
+                       return Argument<typename std::tuple_element<index, std::tuple<Arguments...>>::type>(arg);
                }
 
                Routine *operator()(const char *name, ...);
@@ -2321,12 +2307,6 @@ namespace rr
        {
        };
 
-       template<int index, typename Return, typename... Arguments>
-       Argument<typename ArgI<index, Arguments...>::Type> Arg(Function<Return(Arguments...)> &function)
-       {
-               return Argument<typename ArgI<index, Arguments...>::Type>(function.arg(index));
-       }
-
        RValue<Long> Ticks();
 }