SRD

unique_ptr - thread

SRD
Jan 27th, 2018
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.79 KB | None | 0 0
  1.     template <class A, class B>
  2.     class MyMaps
  3.     {
  4.         private:
  5.             std::shared_ptr<A> aa;
  6.             std::shared_ptr<B> bb;
  7.  
  8.         public:
  9.             MyMaps() { }
  10.             MyMaps(std::shared_ptr<A> a, std::shared_ptr<B> b :
  11.                 aa(a), bb(b) { }
  12.  
  13.             void operator()() {
  14.                 cout << "operator()()" << endl;
  15.             }
  16.     };
  17.  
  18.  
  19.  
  20.     std::unique_ptr<MyMaps<AMap, BMap>> c;
  21.  
  22.     a = make_shared<AMap>();
  23.     b = make_shared<BMap>();
  24.  
  25.     c = std::unique_ptr<MyMaps<AMap, BMap>> {
  26.         new MyMaps<AMap, BMap>(a, b)
  27.     };
  28.  
  29. /* How does one call the MyMaps functor using std::thread?
  30.    The following creates some pretty large errors. Is this
  31.    even close to correct? */
  32.  
  33.     std::thread t(MyMaps<AMap, BMap>(), std::move(c));
Advertisement
Add Comment
Please, Sign In to add comment