The vbs tools - vbs_ls, vbs_rm, vbs_fs - for listing, removing and mounting vbs and Mark6 format scattered VLBI recordings on FlexBuff and Mark6 systems
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

48 lines
900 B

  1. #ifndef AUTO_ARRAY_H
  2. #define AUTO_ARRAY_H
  3. #include <sys/types.h>
  4. template <typename T>
  5. struct auto_array {
  6. public:
  7. typedef T element_type;
  8. auto_array() :
  9. m_ptr( 0 )
  10. {}
  11. auto_array(T* const p):
  12. m_ptr( p )
  13. {}
  14. auto_array(const auto_array<T>& other):
  15. m_ptr( other.m_ptr )
  16. { other.m_ptr = 0; }
  17. auto_array<T>& operator=(const auto_array<T>& other) {
  18. if( this!=&other ) {
  19. m_ptr = other.m_ptr;
  20. other.m_ptr = 0;
  21. }
  22. return *this;
  23. }
  24. T& operator[](size_t idx) {
  25. return m_ptr[idx];
  26. }
  27. T const& operator[](size_t idx) const {
  28. return m_ptr[idx];
  29. }
  30. ~auto_array() {
  31. delete [] m_ptr;
  32. }
  33. private:
  34. element_type* m_ptr;
  35. };
  36. #endif