unwrap_tuple

defined in header <pplpp.h>
template<typename Func>
unwrapperedFunctor<Func> unwrap_tuple(const Func& f)

Summary

Creates a functor that unwraps the return tuple of the input functor. We can use this function to pass data in task continuations.

Parameters

  • func: A functor which returns a tuple of tasks or Async operations.

Return values

A functor which returns a task, and the task returns the unwrapped tuple.
If the input functor returns std::tuple<task<T>, IAsyncOperation<StorageFile>^>, the return value of this function is a functor which returns std::tuple<T, StorageFile^>.

Remarks

The return tuple of input functor cannot include task<void>

Sample

auto folder = KnownFolders::PicturesLibrary;
auto getFileTask = concurrency::create_task(pplpp::unwrap_tuple([this, folder]{
auto task1 = concurrency::create_task([]{return 1; });
auto tuple = std::make_tuple(task1, folder->GetFileAsync("sample.txt"));
              return tuple;
}));

getFileTask.then([this](std::tuple<int, StorageFile^ > tuple){
               auto v1 = std::get<0>(tuple);
               auto v2 = std::get<1>(tuple);
});

Last edited Jul 8, 2013 at 9:43 PM by gbb21, version 3

Comments

No comments yet.