fork(1) download
  1. #include <utility>
  2.  
  3. template<class Container>
  4. class SequenceContainerWrapper
  5. {
  6. Container cont;
  7. public:
  8. using value_type = typename Container::value_type;
  9. using reference = typename Container::reference;
  10. using size_type = typename Container::size_type;
  11. SequenceContainerWrapper(Container init) : cont(std::move(init)) {}
  12. reference operator[] (size_type n) {return cont[n];}
  13. };
  14.  
  15. #include <iostream>
  16. #include <vector>
  17. #include <array>
  18.  
  19. int main()
  20. {
  21. SequenceContainerWrapper<std::vector<int>> vec({1,2,3,4});
  22. std::cout << vec[2] << '\n';
  23. SequenceContainerWrapper<std::array<int, 4>> arr({1,2,3,4});
  24. std::cout << arr[2] << '\n';
  25. }
  26.  
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
3
3