SRD

functor

SRD
Jun 14th, 2017
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 KB | None | 0 0
  1. /* I have a class template like such ... */
  2.  
  3. template <typename T>
  4. class MyCollection
  5. {
  6.     private:
  7.         shared_ptr<T> col;
  8.     public:
  9.         MyCollection(shared_ptr<T> t) : col(t) {
  10.             // ...
  11.         }
  12.  
  13.         void operator()() { /* I want to call this */ }
  14. }
  15.  
  16. // And I instantiate it like this ...
  17.     mm = make_shared<MyMap>();
  18.     MyCollection<MyMap> mc(mm);
  19.  
  20. /* But what I'm wanting to do is call the functor (operator()), but this doesn't work ... */
  21.     mc()
  22.  
  23. Thoughts?
Advertisement
Add Comment
Please, Sign In to add comment