/home/ntakagi/work/STLport-5.1.5/stlport/stl/_carray.hGo to the documentation of this file.00001 /* 00002 * Copyright (c) 2005 00003 * Francois Dumont 00004 * 00005 * This material is provided "as is", with absolutely no warranty expressed 00006 * or implied. Any use is at your own risk. 00007 * 00008 * Permission to use or copy this software for any purpose is hereby granted 00009 * without fee, provided the above notices are retained on all copies. 00010 * Permission to modify the code and to distribute modified code is granted, 00011 * provided the above notices are retained, and a notice that the code was 00012 * modified is included with the above copyright notice. 00013 * 00014 */ 00015 00016 /* NOTE: This is an internal header file, included by other STL headers. 00017 * You should not attempt to use it directly. 00018 */ 00019 00020 #ifndef _STLP_CARRAY_H 00021 #define _STLP_CARRAY_H 00022 00023 /* Purpose: Mimic a pur C array with the additionnal feature of 00024 * being able to be used with type not default constructible. 00025 */ 00026 00027 #ifndef _STLP_INTERNAL_CONSTRUCT_H 00028 # include <stl/_construct.h> 00029 #endif 00030 00031 _STLP_BEGIN_NAMESPACE 00032 00033 _STLP_MOVE_TO_PRIV_NAMESPACE 00034 00035 template <class _Tp, size_t _Nb> 00036 struct _CArray { 00037 _CArray (const _Tp& __val) { 00038 for (size_t __i = 0; __i < _Nb; ++__i) { 00039 _Copy_Construct(__REINTERPRET_CAST(_Tp*, _M_data + __i * sizeof(_Tp)), __val); 00040 } 00041 } 00042 00043 ~_CArray() { 00044 _Destroy_Range(__REINTERPRET_CAST(_Tp*, _M_data + 0), 00045 __REINTERPRET_CAST(_Tp*, _M_data + _Nb * sizeof(_Tp))); 00046 } 00047 00048 _Tp& operator [] (size_t __i) { 00049 _STLP_ASSERT(__i < _Nb) 00050 return *__REINTERPRET_CAST(_Tp*, _M_data + __i * sizeof(_Tp)); 00051 } 00052 00053 private: 00054 char _M_data[sizeof(_Tp) * _Nb]; 00055 }; 00056 00057 _STLP_MOVE_TO_STD_NAMESPACE 00058 00059 _STLP_END_NAMESPACE 00060 00061 #endif //_STLP_CARRAY_H
Generated on Mon Mar 10 15:32:20 2008 by ![]() |