STLSoft - ... Robust, Lightweight, Cross-platform, Template Software ... ATLSTL - Template Software for the Active Template Library COMSTL - The Standard Template Library meets the Component Object Model .netSTL - Standard Template Library meets the Microsoft.NET Common Language Runtime InetSTL - The Standard Template Library meets WinInet MFCSTL - Template Software for the Microsoft Foundation Classes UNIXSTL - Template Software for the UNIX Operating System WinSTL - where the Standard Template Library meets the Win32 API

Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

stlsoft_array_policies.h

Go to the documentation of this file.
00001 /* 
00002  * File:        stlsoft_array_policies.h
00003  *
00004  * Purpose:     Contains the construction policies for the array (fixed and
00005  *              frame) classes.
00006  *
00007  * Created:     1st September 2002
00008  * Updated:     11th September 2004
00009  *
00010  * Home:        http://stlsoft.org/
00011  *
00012  * Copyright (c) 2002-2004, Matthew Wilson and Synesis Software
00013  * All rights reserved.
00014  *
00015  * Redistribution and use in source and binary forms, with or without
00016  * modification, are permitted provided that the following conditions are met:
00017  *
00018  * - Redistributions of source code must retain the above copyright notice, this
00019  *   list of conditions and the following disclaimer.
00020  * - Redistributions in binary form must reproduce the above copyright notice,
00021  *   this list of conditions and the following disclaimer in the documentation
00022  *   and/or other materials provided with the distribution.
00023  * - Neither the name(s) of Matthew Wilson and Synesis Software nor the names of
00024  *   any contributors may be used to endorse or promote products derived from
00025  *   this software without specific prior written permission.
00026  *
00027  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00028  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00029  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00030  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00031  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00032  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00033  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00034  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00035  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00036  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00037  * POSSIBILITY OF SUCH DAMAGE.
00038  *
00039  * 
00040 
00041 
00045 
00046 #ifndef STLSOFT_INCL_H_STLSOFT_ARRAY_POLICIES
00047 #define STLSOFT_INCL_H_STLSOFT_ARRAY_POLICIES
00048 
00049 #ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION
00050 # define STLSOFT_VER_H_STLSOFT_ARRAY_POLICIES_MAJOR     2
00051 # define STLSOFT_VER_H_STLSOFT_ARRAY_POLICIES_MINOR     0
00052 # define STLSOFT_VER_H_STLSOFT_ARRAY_POLICIES_REVISION  1
00053 # define STLSOFT_VER_H_STLSOFT_ARRAY_POLICIES_EDIT      107
00054 #endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */
00055 
00056 /* 
00057  * Includes
00058  */
00059 
00060 #ifndef STLSOFT_INCL_H_STLSOFT
00061 # include "stlsoft.h"   // Include the STLSoft root header
00062 #endif /* !STLSOFT_INCL_H_STLSOFT */
00063 
00064 /* 
00065  * Namespace
00066  */
00067 
00068 #ifndef _STLSOFT_NO_NAMESPACE
00069 namespace stlsoft
00070 {
00071 #endif /* _STLSOFT_NO_NAMESPACE */
00072 
00073 /* 
00074  * Construction policy classes
00075  */
00076 
00083 template <ss_typename_param_k T>
00084 struct do_construction
00085 {
00086     enum
00087     {
00088         value = true 
00089     };
00090 };
00091 
00092 #ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION
00093 
00094 STLSOFT_TEMPLATE_SPECIALISATION
00095 struct do_construction<ss_sint8_t>  { enum { value = false }; };
00096 
00097 STLSOFT_TEMPLATE_SPECIALISATION
00098 struct do_construction<ss_uint8_t>  { enum { value = false }; };
00099 
00100 STLSOFT_TEMPLATE_SPECIALISATION
00101 struct do_construction<ss_sint16_t> { enum { value = false }; };
00102 
00103 STLSOFT_TEMPLATE_SPECIALISATION
00104 struct do_construction<ss_uint16_t> { enum { value = false }; };
00105 
00106 STLSOFT_TEMPLATE_SPECIALISATION
00107 struct do_construction<ss_sint32_t> { enum { value = false }; };
00108 
00109 STLSOFT_TEMPLATE_SPECIALISATION
00110 struct do_construction<ss_uint32_t> { enum { value = false }; };
00111 
00112 #ifdef STLSOFT_CF_64BIT_INT_SUPPORT
00113 STLSOFT_TEMPLATE_SPECIALISATION
00114 struct do_construction<ss_sint64_t> { enum { value = false }; };
00115 
00116 STLSOFT_TEMPLATE_SPECIALISATION
00117 struct do_construction<ss_uint64_t> { enum { value = false }; };
00118 #endif /* STLSOFT_CF_64BIT_INT_SUPPORT */
00119 
00120 STLSOFT_TEMPLATE_SPECIALISATION
00121 struct do_construction<float>       { enum { value = false }; };
00122 
00123 STLSOFT_TEMPLATE_SPECIALISATION
00124 struct do_construction<double>      { enum { value = false }; };
00125 
00126 STLSOFT_TEMPLATE_SPECIALISATION
00127 struct do_construction<long double> { enum { value = false }; };
00128 
00129 #ifdef __STLSOFT_CF_NATIVE_BOOL_SUPPORT
00130 STLSOFT_TEMPLATE_SPECIALISATION
00131 struct do_construction<ss_bool_t>   { enum { value = false }; };
00132 #endif /* __STLSOFT_CF_NATIVE_BOOL_SUPPORT */
00133 
00134 #endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */
00135 
00136 
00138 struct do_construction_always
00139 {
00140     enum { value = true };
00141 };
00142 
00144 struct do_construction_never
00145 {
00146     enum { value = false };
00147 };
00148 
00149 /*
00150 template<   ss_typename_param_k T
00151         ,   ss_typename_param_k P
00152 struct inplace_range_construct
00153 {
00154 public:
00155     void
00156 }
00157  */
00158 
00159 #ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION
00160 
00161 template<   ss_typename_param_k T
00162         ,   ss_typename_param_k A
00163         ,   ss_typename_param_k P
00164         >
00165 struct array_range_initialiser
00166 {
00167     typedef T   value_type;
00168     typedef T   *pointer;
00169     typedef A   allocator_type;
00170     typedef P   initialisation_policy_type;
00171 
00172 public:
00173     static void construct(allocator_type &ator, pointer p, ss_size_t n)
00174     {
00175         if(initialisation_policy_type::value)
00176         {
00177             construct(ator, p, n, value_type());
00178         }
00179         else
00180         {
00181 #if 1
00182             memset(p, 0, n * sizeof(value_type));
00183 #else /* ? 0 */
00184             fill_n(p, n, 0);
00185 #endif /* 0 */
00186         }
00187     }
00188 
00189     static void construct(allocator_type &ator, pointer p, ss_size_t n, value_type const &value)
00190     {
00191         for(pointer e = p + n; p != e; ++p)
00192         {
00193             ator.construct(p, value);
00194         }
00195     }
00196 
00197     static void destroy(allocator_type &ator, pointer p, ss_size_t n)
00198     {
00199         if(initialisation_policy_type::value)
00200         {
00201             for(pointer e = p + n; p != e; ++p)
00202             {
00203                 ator.destroy(p);
00204             }
00205         }
00206     }
00207 };
00208 
00209 #endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */
00210 
00211 /* 
00212 
00213 #ifndef _STLSOFT_NO_NAMESPACE
00214 } // namespace stlsoft
00215 #endif /* _STLSOFT_NO_NAMESPACE */
00216 
00217 /* 
00218 
00219 #endif /* !STLSOFT_INCL_H_STLSOFT_ARRAY_POLICIES */
00220 
00221 /* 

STLSoft Libraries documentation © Synesis Software Pty Ltd, 2001-2004