5 * This material is provided "as is", with absolutely no warranty expressed
6 * or implied. Any use is at your own risk.
8 * Permission to use or copy this software for any purpose is hereby granted
9 * without fee, provided the above notices are retained on all copies.
10 * Permission to modify the code and to distribute modified code is granted,
11 * provided the above notices are retained, and a notice that the code was
12 * modified is included with the above copyright notice.
16 /* NOTE: This is an internal header file, included by other STL headers.
17 * You should not attempt to use it directly.
20 #ifndef _STLP_CARRAY_H
21 #define _STLP_CARRAY_H
23 /* Purpose: Mimic a pur C array with the additionnal feature of
24 * being able to be used with type not default constructible.
27 #ifndef _STLP_INTERNAL_CONSTRUCT_H
28 # include <stl/_construct.h>
33 _STLP_MOVE_TO_PRIV_NAMESPACE
35 template <class _Tp
, size_t _Nb
>
37 _CArray (const _Tp
& __val
) {
38 for (size_t __i
= 0; __i
< _Nb
; ++__i
) {
39 _Copy_Construct(__REINTERPRET_CAST(_Tp
*, _M_data
+ __i
* sizeof(_Tp
)), __val
);
44 _Destroy_Range(__REINTERPRET_CAST(_Tp
*, _M_data
+ 0),
45 __REINTERPRET_CAST(_Tp
*, _M_data
+ _Nb
* sizeof(_Tp
)));
48 _Tp
& operator [] (size_t __i
) {
49 _STLP_ASSERT(__i
< _Nb
)
50 return *__REINTERPRET_CAST(_Tp
*, _M_data
+ __i
* sizeof(_Tp
));
54 char _M_data
[sizeof(_Tp
) * _Nb
];
57 _STLP_MOVE_TO_STD_NAMESPACE
61 #endif //_STLP_CARRAY_H