fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. #include <vector>
  5.  
  6. template<class T>
  7. T* get_somthing(){
  8. std::vector<T> vec = {1,2,3}; //T is trivally-copyable
  9.  
  10. static std::vector<T> static_vector;
  11.  
  12. static_vector = std::move(vec);
  13.  
  14. return static_vector.data();
  15. }
  16.  
  17. int main() {
  18. {
  19. int * is = get_somthing<int>();
  20. std::cout << is[0] << " " << is[1] << " " << is[2];
  21. }
  22. int * is = get_somthing<int>();
  23. std::cout << is[0] << " " << is[1] << " " << is[2];
  24.  
  25.  
  26. return 0;
  27. }
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
1 2 31 2 3