epoc32/include/tools/stlport/stl/_carray.h
branchSymbian3
changeset 4 837f303aceeb
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/tools/stlport/stl/_carray.h	Wed Mar 31 12:33:34 2010 +0100
     1.3 @@ -0,0 +1,61 @@
     1.4 +/*
     1.5 + * Copyright (c) 2005
     1.6 + * Francois Dumont
     1.7 + *
     1.8 + * This material is provided "as is", with absolutely no warranty expressed
     1.9 + * or implied. Any use is at your own risk.
    1.10 + *
    1.11 + * Permission to use or copy this software for any purpose is hereby granted
    1.12 + * without fee, provided the above notices are retained on all copies.
    1.13 + * Permission to modify the code and to distribute modified code is granted,
    1.14 + * provided the above notices are retained, and a notice that the code was
    1.15 + * modified is included with the above copyright notice.
    1.16 + *
    1.17 + */
    1.18 +
    1.19 +/* NOTE: This is an internal header file, included by other STL headers.
    1.20 + *   You should not attempt to use it directly.
    1.21 + */
    1.22 +
    1.23 +#ifndef _STLP_CARRAY_H
    1.24 +#define _STLP_CARRAY_H
    1.25 +
    1.26 +/* Purpose: Mimic a pur C array with the additionnal feature of
    1.27 + * being able to be used with type not default constructible.
    1.28 + */
    1.29 +
    1.30 +#ifndef _STLP_INTERNAL_CONSTRUCT_H
    1.31 +#  include <stl/_construct.h>
    1.32 +#endif
    1.33 +
    1.34 +_STLP_BEGIN_NAMESPACE
    1.35 +
    1.36 +_STLP_MOVE_TO_PRIV_NAMESPACE
    1.37 +
    1.38 +template <class _Tp, size_t _Nb>
    1.39 +struct _CArray {
    1.40 +  _CArray (const _Tp& __val) {
    1.41 +    for (size_t __i = 0; __i < _Nb; ++__i) {
    1.42 +      _Copy_Construct(__REINTERPRET_CAST(_Tp*, _M_data + __i * sizeof(_Tp)), __val);
    1.43 +    }
    1.44 +  }
    1.45 +
    1.46 +  ~_CArray() {
    1.47 +    _Destroy_Range(__REINTERPRET_CAST(_Tp*, _M_data + 0),
    1.48 +                   __REINTERPRET_CAST(_Tp*, _M_data + _Nb * sizeof(_Tp)));
    1.49 +  }
    1.50 +
    1.51 +  _Tp& operator [] (size_t __i) {
    1.52 +    _STLP_ASSERT(__i < _Nb)
    1.53 +    return *__REINTERPRET_CAST(_Tp*, _M_data + __i * sizeof(_Tp));
    1.54 +  }
    1.55 +
    1.56 +private:
    1.57 +  char _M_data[sizeof(_Tp) * _Nb];
    1.58 +};
    1.59 +
    1.60 +_STLP_MOVE_TO_STD_NAMESPACE
    1.61 +
    1.62 +_STLP_END_NAMESPACE
    1.63 +
    1.64 +#endif //_STLP_CARRAY_H