ReactOS  0.4.14-dev-1034-g1e60116
_carray.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2005
3  * Francois Dumont
4  *
5  * This material is provided "as is", with absolutely no warranty expressed
6  * or implied. Any use is at your own risk.
7  *
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.
13  *
14  */
15 
16 /* NOTE: This is an internal header file, included by other STL headers.
17  * You should not attempt to use it directly.
18  */
19 
20 #ifndef _STLP_CARRAY_H
21 #define _STLP_CARRAY_H
22 
23 /* Purpose: Mimic a pur C array with the additionnal feature of
24  * being able to be used with type not default constructible.
25  */
26 
27 #ifndef _STLP_INTERNAL_CONSTRUCT_H
28 # include <stl/_construct.h>
29 #endif
30 
32 
34 
35 template <class _Tp, size_t _Nb>
36 struct _CArray {
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);
40  }
41  }
42 
45  __REINTERPRET_CAST(_Tp*, _M_data + _Nb * sizeof(_Tp)));
46  }
47 
48  _Tp& operator [] (size_t __i) {
49  _STLP_ASSERT(__i < _Nb)
50  return *__REINTERPRET_CAST(_Tp*, _M_data + __i * sizeof(_Tp));
51  }
52 
53 private:
54  char _M_data[sizeof(_Tp) * _Nb];
55 };
56 
58 
60 
61 #endif //_STLP_CARRAY_H
_CArray(const _Tp &__val)
Definition: _carray.h:37
#define _STLP_MOVE_TO_PRIV_NAMESPACE
Definition: features.h:524
~_CArray()
Definition: _carray.h:43
#define _STLP_MOVE_TO_STD_NAMESPACE
Definition: features.h:525
void _Copy_Construct(_Tp *__p, const _Tp &__val)
Definition: _construct.h:130
_STLP_INLINE_LOOP _InputIter const _Tp & __val
Definition: _algobase.h:656
#define __REINTERPRET_CAST(__x, __y)
Definition: features.h:586
void _Destroy_Range(_ForwardIterator __first, _ForwardIterator __last)
Definition: _construct.h:219
#define _STLP_END_NAMESPACE
Definition: features.h:503
#define _STLP_ASSERT(expr)
Definition: _debug.h:165
char _M_data[sizeof(_Tp) *_Nb]
Definition: _carray.h:54
_Tp & operator [](size_t __i)
Definition: _carray.h:48
#define _STLP_BEGIN_NAMESPACE
Definition: features.h:501