Guest User

anonam

a guest
Dec 6th, 2015
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.32 KB | None | 0 0
  1. template< typename T >
  2. struct with_pimpl {
  3. protected:
  4.     template< typename ... Args >
  5.     explicit with_pimpl (Args &&... args) : pimpl (new (this->pimpl_mem) T (std::forward< Args > (args)...)) {}
  6.     ~with_pimpl () { this->pimpl->~T (); }
  7. protected:
  8.     T *pimpl = nullptr;
  9. private:
  10.     char pimpl_mem [sizeof (T)] = { 0 };
  11. };
Advertisement
Add Comment
Please, Sign In to add comment