Playing Devil's Advocate: besides the obvious intent of the document, since this is a private attribute, you cannot use the const keyword and not modify it separately from the init method.
Actually, const_cast can be undefined here, and of course I prefer not to run in those dark corners, no matter what workarounds.
class EPWM { private: volatile EPWM_REGS* regs;
Although, repeat your question: while the raw array cannot be configured by default, you can write an array class, which may be.
namespace detail { template <class T, size_t N, size_t index> struct At { static T& Do(Array<T,N>& array) { return At<T,N-1,index-1>::Do(array.tail()); } }; template <class T, size_t N> struct At<T,N,0> { static T& Do(Array<T,N>& array) { return array[0]; } }; template <class T, size_t index> struct At<T,0,index> {}; template <class T> struct At<T,0,0> {}; } // namespace detail template <class T, size_t N> class array { public: typedef T value_type; static const size_t Length = N; array(): mHead(), mTail() {} array(const array& rhs): mHead(rhs.mHead), mTail(rhs.mTail) {} // Don't know whether it will be optimized or not // Not sure I can use pointer arithmetic either :p T& operator[](size_t index) { return index == 0 ? mHead : mTail[index-1]; } // Compile time access template <size_t index> T& at() { return detail::At< T, N, index >::Do(*this); } private: T mHead; array<T, N-1> mTail; }; // class array<T,N> template <class T> class array<T,1> { public: typedef T value_type; static const size_t Length = 1; array(): mHead() {} array(const array& rhs): mHead(rhs.mHead) {} T& operator[](size_t index) { return mHead; } // or error handling ;) private: T mHead; }; // class array<T,1> template <class T> class array<T,0> {}; // int[0] does not work (stack) so...
Ok ... maybe not as efficient as a real array ... you can always switch to preprocessor generation:
template <class T> class Array4 { public: Array4(): m0(), m1(), m2(), m3() {} Array4(const Array4& rhs): m0(rhs.m0), m1(rhs.m1), m2(rhs.m2), m3(rhs.m3) {} T& operator[](size_t index) { return *(&m0 + index); } private: T m0; T m1; T m2; T m3; };