Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. template<typename T>
  2. class Array : public std::vector<T>
  3. {
  4. public:
  5.     explicit Array(const typename _Alloc& all)
  6.         : std::vector<T>(all)
  7.     {
  8.     }
  9.  
  10.     explicit Array(size_type n, const T& value = T(), const typename _Alloc& all = _Alloc())
  11.         : std::vector<T>(n, value, all)
  12.     {
  13.     }
  14.  
  15.     explicit Array()
  16.         : std::vector<T>()
  17.     {
  18.     }
  19.  
  20.     template<int size>
  21.     Array(T (&values)[size])
  22.         : std::vector<T>(sizeof(values) / sizeof(T))
  23.     {
  24.         std::copy(values, values + sizeof(values) / sizeof(T), begin());
  25.     }
  26.  
  27.     const T* Pointer() const { return &front(); }
  28.  
  29.     void operator +=(const T& value)
  30.     {
  31.         push_back(value);
  32.     }
  33.  
  34.     void ForEach(std::tr1::function<void (T&)> fun)
  35.     {
  36.         std::for_each(begin(), end(), fun);
  37.     }
  38. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement