daily pastebin goal
90%
SHARE
TWEET

Untitled

a guest Dec 26th, 2014 201 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
  1. #include <thread>
  2. #include future>
  3.  
  4. void func( std::promise<int> && p, const int arg ) {
  5.     p.set_value( arg << 1 );
  6. }
  7.  
  8. int main( void ) {
  9.         std::promise<int> p;
  10.         auto f = p.get_future();
  11.         int val = 6;
  12.         std::thread t(&func, val );
  13.         t.join();
  14.  
  15.         //do_stuff();
  16.  
  17.         int ret = f.get();     
  18.         return ret;
  19. }
  20.  
  21.  
  22. /*
  23. uninteligible garbage from linker:
  24.  
  25. In file included from C:/mingw-w64/i686-4.9.2-posix-dwarf-rt_v3-rev1/mingw32/i68
  26. 6-w64-mingw32/include/c++/thread:39:0,
  27.                  from promise.cpp:1:
  28. 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)>':
  29. 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&}]'
  30. promise.cpp:12:27:   required from here
  31. 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)>'
  32.        typedef typename result_of<_Callable(_Args...)>::type result_type;
  33.                                                              ^
  34. 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)>'
  35.          _M_invoke(_Index_tuple<_Indices...>)
  36.          ^
  37. */
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top