fork download
  1. #include <iostream>
  2. #include <memory>
  3. #include <vector>
  4. #include <string>
  5.  
  6. typedef std::shared_ptr<void> Any;
  7. typedef std::vector<Any> VAny;
  8.  
  9. struct S {
  10. std::string T;
  11. };
  12.  
  13. int main() {
  14.  
  15. Any M(new S);
  16. static_cast<S*>(M.get())->T = "Hogehage!";
  17. VAny V;
  18.  
  19. V.push_back(M);
  20.  
  21. std::cout << static_cast<S*>(V[0].get())->T << std::endl;
  22.  
  23. return 0;
  24. }
Success #stdin #stdout 0s 16056KB
stdin
Standard input is empty
stdout
Hogehage!