williamr@2: /* williamr@2: * Copyright (c) 2005 williamr@2: * Francois Dumont williamr@2: * williamr@2: * This material is provided "as is", with absolutely no warranty expressed williamr@2: * or implied. Any use is at your own risk. williamr@2: * williamr@2: * Permission to use or copy this software for any purpose is hereby granted williamr@2: * without fee, provided the above notices are retained on all copies. williamr@2: * Permission to modify the code and to distribute modified code is granted, williamr@2: * provided the above notices are retained, and a notice that the code was williamr@2: * modified is included with the above copyright notice. williamr@2: * williamr@2: */ williamr@2: williamr@2: /* NOTE: This is an internal header file, included by other STL headers. williamr@2: * You should not attempt to use it directly. williamr@2: */ williamr@2: williamr@2: #ifndef _STLP_CARRAY_H williamr@2: #define _STLP_CARRAY_H williamr@2: williamr@2: /* Purpose: Mimic a pur C array with the additionnal feature of williamr@2: * being able to be used with type not default constructible. williamr@2: */ williamr@2: williamr@2: #ifndef _STLP_INTERNAL_CONSTRUCT_H williamr@2: # include williamr@2: #endif williamr@2: williamr@2: _STLP_BEGIN_NAMESPACE williamr@2: williamr@2: _STLP_MOVE_TO_PRIV_NAMESPACE williamr@2: williamr@2: template williamr@2: struct _CArray { williamr@2: _CArray (const _Tp& __val) { williamr@2: for (size_t __i = 0; __i < _Nb; ++__i) { williamr@2: _Copy_Construct(__REINTERPRET_CAST(_Tp*, _M_data + __i * sizeof(_Tp)), __val); williamr@2: } williamr@2: } williamr@2: williamr@2: ~_CArray() { williamr@2: _Destroy_Range(__REINTERPRET_CAST(_Tp*, _M_data + 0), williamr@2: __REINTERPRET_CAST(_Tp*, _M_data + _Nb * sizeof(_Tp))); williamr@2: } williamr@2: williamr@2: _Tp& operator [] (size_t __i) { williamr@2: _STLP_ASSERT(__i < _Nb) williamr@2: return *__REINTERPRET_CAST(_Tp*, _M_data + __i * sizeof(_Tp)); williamr@2: } williamr@2: williamr@2: private: williamr@2: char _M_data[sizeof(_Tp) * _Nb]; williamr@2: }; williamr@2: williamr@2: _STLP_MOVE_TO_STD_NAMESPACE williamr@2: williamr@2: _STLP_END_NAMESPACE williamr@2: williamr@2: #endif //_STLP_CARRAY_H