Merge pull request #13745 from smirnov-alexey:gapi_add_gout_overloading
authorAlexey Smirnov <alexey.smirnov@intel.com>
Fri, 8 Feb 2019 10:16:50 +0000 (13:16 +0300)
committerAlexander Alekhin <alexander.a.alekhin@gmail.com>
Fri, 8 Feb 2019 10:16:50 +0000 (13:16 +0300)
* Add GOut overloading for tuple of parameter pack

* Move getGOut_impl into namespace and add const to input references

modules/gapi/include/opencv2/gapi/gproto.hpp

index 8b53d9b..7f50623 100644 (file)
@@ -76,6 +76,30 @@ template<typename... Ts> inline GProtoOutputArgs GOut(Ts&&... ts)
     return GProtoOutputArgs(detail::packArgs(std::forward<Ts>(ts)...));
 }
 
+namespace detail
+{
+    // Extract elements form tuple
+    // FIXME: Someday utilize a generic tuple_to_vec<> routine
+    template<typename... Ts, int... Indexes>
+    static GProtoOutputArgs getGOut_impl(const std::tuple<Ts...>& ts, detail::Seq<Indexes...>)
+    {
+        return GProtoOutputArgs{ detail::packArgs(std::get<Indexes>(ts)...)};
+    }
+}
+
+template<typename... Ts> inline GProtoOutputArgs GOut(const std::tuple<Ts...>& ts)
+{
+    // TODO: think of std::forward(ts)
+    return detail::getGOut_impl(ts, typename detail::MkSeq<sizeof...(Ts)>::type());
+}
+
+// Takes rvalue as input arg
+template<typename... Ts> inline GProtoOutputArgs GOut(std::tuple<Ts...>&& ts)
+{
+    // TODO: think of std::forward(ts)
+    return detail::getGOut_impl(ts, typename detail::MkSeq<sizeof...(Ts)>::type());
+}
+
 // Extract run-time arguments from node origin
 // Can be used to extract constant values associated with G-objects
 // (like GScalar) at graph construction time