Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <thread>
- #include future>
- void func( std::promise<int> && p, const int arg ) {
- p.set_value( arg << 1 );
- }
- int main( void ) {
- std::promise<int> p;
- auto f = p.get_future();
- int val = 6;
- std::thread t(&func, val );
- t.join();
- //do_stuff();
- int ret = f.get();
- return ret;
- }
- /*
- uninteligible garbage from linker:
- In file included from C:/mingw-w64/i686-4.9.2-posix-dwarf-rt_v3-rev1/mingw32/i68
- 6-w64-mingw32/include/c++/thread:39:0,
- from promise.cpp:1:
- C:/mingw-w64/i686-4.9.2-posix-dwarf-rt_v3-rev1/mingw32/i686-w64-mingw32/include/c++/functional: In instantiation of 'struct std::_Bind_simple<void (*(int))(std::promise<int>&&, int)>':
- C:/mingw-w64/i686-4.9.2-posix-dwarf-rt_v3-rev1/mingw32/i686-w64-mingw32/include/c++/thread:137:47: required from 'std::thread::thread(_Callable&&, _Args&& ...) [with _Callable = void (*)(std::promise<int>&&, int); _Args = {int&}]'
- promise.cpp:12:27: required from here
- C:/mingw-w64/i686-4.9.2-posix-dwarf-rt_v3-rev1/mingw32/i686-w64-mingw32/include/c++/functional:1665:61: error: no type named 'type' in 'class std::result_of<void (*(int))(std::promise<int>&&, int)>'
- typedef typename result_of<_Callable(_Args...)>::type result_type;
- ^
- C:/mingw-w64/i686-4.9.2-posix-dwarf-rt_v3-rev1/mingw32/i686-w64-mingw32/include/c++/functional:1695:9: error: no type named 'type' in 'class std::result_of<void (*(int))(std::promise<int>&&, int)>'
- _M_invoke(_Index_tuple<_Indices...>)
- ^
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement