fork download
  1. #include <iostream>
  2. #include <memory>
  3. using namespace std;
  4.  
  5.  
  6. class T{
  7. public: int value;
  8. public: T(int a=1234){
  9. value = a;
  10. }
  11. };
  12. int main() {
  13. std::unique_ptr<T> t1 = std::unique_ptr<T>(new T(1));
  14. void* databaseNew=operator new [](sizeof(std::unique_ptr<T>));
  15. std::unique_ptr<T>* t1ptr=static_cast<std::unique_ptr<T>*>(databaseNew);
  16. new (t1ptr) std::unique_ptr<T>(std::move(t1));
  17. return 0;
  18. }
  19.  
Success #stdin #stdout 0s 3464KB
stdin
Standard input is empty
stdout
Standard output is empty