Extended MaximInterface

Dependents:   mbed_DS28EC20_GPIO

Revision:
6:a8c83a2e6fa4
Parent:
0:f77ad7f72d04
Child:
7:471901a04573
--- a/Utilities/array.hpp	Fri Jan 19 10:25:02 2018 -0600
+++ b/Utilities/array.hpp	Wed Jan 23 13:11:04 2019 -0600
@@ -55,58 +55,90 @@
   typedef std::reverse_iterator<iterator> reverse_iterator;
   typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
 
-  // Element access
+  /// @name Element access
+  /// @{
   reference operator[](size_type pos) {
     return const_cast<reference>(
         static_cast<const array &>(*this).operator[](pos));
   }
-  const_reference operator[](size_type pos) const { return _buffer[pos]; }
+  
+  const_reference operator[](size_type pos) const { return data()[pos]; }
+  
   reference front() {
     return const_cast<reference>(static_cast<const array &>(*this).front());
   }
-  const_reference front() const { return _buffer[0]; }
+  
+  const_reference front() const { return operator[](0); }
+  
   reference back() {
     return const_cast<reference>(static_cast<const array &>(*this).back());
   }
-  const_reference back() const { return _buffer[size() - 1]; }
+  
+  const_reference back() const { return operator[](size() - 1); }
+  
   pointer data() {
     return const_cast<pointer>(static_cast<const array &>(*this).data());
   }
+  
   const_pointer data() const { return _buffer; }
+  /// @}
 
-  // Iterators
+  /// @name Iterators
+  /// @{  
   iterator begin() {
     return const_cast<iterator>(static_cast<const array &>(*this).cbegin());
   }
+  
   const_iterator begin() const { return cbegin(); }
-  const_iterator cbegin() const { return _buffer; }
+  
+  const_iterator cbegin() const { return data(); }
+  
   iterator end() {
     return const_cast<iterator>(static_cast<const array &>(*this).cend());
   }
+  
   const_iterator end() const { return cend(); }
-  const_iterator cend() const { return _buffer + size(); }
+  
+  const_iterator cend() const { return cbegin() + size(); }
+  
   reverse_iterator rbegin() { return reverse_iterator(end()); }
+  
   const_reverse_iterator rbegin() const {
     return const_reverse_iterator(end());
   }
+  
   const_reverse_iterator crbegin() const { return rbegin(); }
+  
   reverse_iterator rend() { return reverse_iterator(begin()); }
+  
   const_reverse_iterator rend() const {
     return const_reverse_iterator(begin());
   }
+  
   const_reverse_iterator crend() const { return rend(); }
+  /// @}
 
-  // Capacity
+  /// @name Capacity
+  /// @{
   static bool empty() { return size() == 0; }
+  
   static size_type size() { return N; }
+  
   static size_type max_size() { return size(); }
-  static const size_type csize =
-      N; ///< Alternative to size() when a constant expression is required.
+  
+  /// Alternative to size() when a constant expression is required.
+  static const size_type csize = N;
+  /// @}
 
-  // Operations
+  /// @name Operations
+  /// @{
   void fill(const_reference value) { std::fill(begin(), end(), value); }
+  
   void swap(array & other) { std::swap_ranges(begin(), end(), other.begin()); }
+  /// @}
 
+  /// @private
+  /// Implementation detail set public to allow aggregate initialization.
   T _buffer[N];
 };