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_associative_container_veneer.h

Go to the documentation of this file.
00001 /* 
00002  * File:        stlsoft_associative_container_veneer.h
00003  *
00004  * Purpose:     RRID (veneer for associative containers)
00005  *
00006  * Created:     2nd October 2002
00007  * Updated:     11th September 2004
00008  *
00009  * Home:        http://stlsoft.org/
00010  *
00011  * Copyright (c) 2002-2004, Matthew Wilson and Synesis Software
00012  * All rights reserved.
00013  *
00014  * Redistribution and use in source and binary forms, with or without
00015  * modification, are permitted provided that the following conditions are met:
00016  *
00017  * - Redistributions of source code must retain the above copyright notice, this
00018  *   list of conditions and the following disclaimer.
00019  * - Redistributions in binary form must reproduce the above copyright notice,
00020  *   this list of conditions and the following disclaimer in the documentation
00021  *   and/or other materials provided with the distribution.
00022  * - Neither the name(s) of Matthew Wilson and Synesis Software nor the names of
00023  *   any contributors may be used to endorse or promote products derived from
00024  *   this software without specific prior written permission.
00025  *
00026  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00027  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00028  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00029  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00030  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00031  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00032  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00033  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00034  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00035  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00036  * POSSIBILITY OF SUCH DAMAGE.
00037  *
00038  * 
00039 
00040 
00044 
00045 #ifndef STLSOFT_INCL_H_STLSOFT_ASSOCIATIVE_CONTAINER_VENEER
00046 #define STLSOFT_INCL_H_STLSOFT_ASSOCIATIVE_CONTAINER_VENEER
00047 
00048 #ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION
00049 # define STLSOFT_VER_H_STLSOFT_ASSOCIATIVE_CONTAINER_VENEER_MAJOR       2
00050 # define STLSOFT_VER_H_STLSOFT_ASSOCIATIVE_CONTAINER_VENEER_MINOR       0
00051 # define STLSOFT_VER_H_STLSOFT_ASSOCIATIVE_CONTAINER_VENEER_REVISION    1
00052 # define STLSOFT_VER_H_STLSOFT_ASSOCIATIVE_CONTAINER_VENEER_EDIT        19
00053 #endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */
00054 
00055 /* 
00056  * Compatibility
00057  */
00058 
00059 /*
00060 [Incompatibilies-start]
00061 __STLSOFT_COMPILER_IS_BORLAND:
00062 [Incompatibilies-end]
00063  */
00064 
00065 /* 
00066  * Includes
00067  */
00068 
00069 #ifndef STLSOFT_INCL_H_STLSOFT
00070 # include "stlsoft.h"               // Include the STLSoft root header
00071 #endif /* !STLSOFT_INCL_H_STLSOFT */
00072 
00073 #if defined(__STLSOFT_COMPILER_IS_BORLAND)
00074 # error stlsoft_associative_container_veneer.h is incompatible with the Borland C/C++ compiler
00075 #endif /* compiler */
00076 
00077 #ifndef STLSOFT_INCL_H_STLSOFT_FUNCTIONALS
00078 # include "stlsoft_functionals.h"   // stlsoft::noop_function
00079 #endif /* !STLSOFT_INCL_H_STLSOFT_FUNCTIONALS */
00080 
00081 /* 
00082  * Namespace
00083  */
00084 
00085 #ifndef _STLSOFT_NO_NAMESPACE
00086 namespace stlsoft
00087 {
00088 #endif /* _STLSOFT_NO_NAMESPACE */
00089 
00090 /* 
00091  * Classes
00092  */
00093 
00099 template<   ss_typename_param_k T
00100         ,   ss_typename_param_k FV
00101 #ifdef __STLSOFT_CF_TEMPLATE_CLASS_DEFAULT_CLASS_ARGUMENT_SUPPORT
00102         ,   ss_typename_param_k FK = noop_function<ss_typename_type_def_k T::key_type>
00103 #else
00104         ,   ss_typename_param_k FK /* = noop_function<T> */
00105 #endif /* __STLSOFT_CF_TEMPLATE_CLASS_DEFAULT_CLASS_ARGUMENT_SUPPORT */
00106         >
00107 class associative_container_veneer
00108     : public T
00109 {
00110 public:
00112     typedef T                                                       container_type;
00114     typedef FV                                                      value_destruction_function_type;
00116     typedef FK                                                      key_destruction_function_type;
00118     typedef associative_container_veneer<T, FV, FK>                 class_type;
00120 private:
00121     typedef T                                                       parent_class_type;
00122 public:
00124     typedef ss_typename_type_k parent_class_type::key_compare       key_compare;
00126     typedef ss_typename_type_k parent_class_type::allocator_type    allocator_type;
00128     typedef ss_typename_type_k parent_class_type::size_type         size_type;
00129 
00130 // Construction
00131 public:
00132 #ifdef __STLSOFT_CF_MEMBER_TEMPLATE_FUNCTION_SUPPORT
00133 
00134     associative_container_veneer()
00135     {}
00136 
00138     associative_container_veneer(class_type const &rhs)
00139         : parent_class_type(rhs)
00140     {}
00141 
00142 #if !defined(__STLSOFT_COMPILER_IS_DMC)
00143 
00144     ss_explicit_k associative_container_veneer(const key_compare& comp)
00145         : parent_class_type(comp)
00146     {}
00148     associative_container_veneer(const key_compare& comp, allocator_type const &a)
00149         : parent_class_type(comp, a)
00150     {}
00152     template <ss_typename_param_k I>
00153     associative_container_veneer(I i1, I i2)
00154         : parent_class_type(i1, i2)
00155     {}
00157     template <ss_typename_param_k I>
00158     associative_container_veneer(I i1, I i2, key_compare const &comp)
00159         : parent_class_type(i1, i2, comp)
00160     {}
00162     template <ss_typename_param_k I>
00163     associative_container_veneer(I i1, I i2, key_compare const &comp, allocator_type const &a)
00164         : parent_class_type(i1, i2, comp, a)
00165     {}
00166 #else
00167     template <ss_typename_param_k N1>
00168     ss_explicit_k associative_container_veneer(N1 n1)
00169         : parent_class_type(n1)
00170     {}
00171     template<   ss_typename_param_k N1
00172             ,   ss_typename_param_k N2
00173             >
00174     associative_container_veneer(N1 n1, N2 n2)
00175         : parent_class_type(n1, n2)
00176     {}
00177     template<   ss_typename_param_k N1
00178             ,   ss_typename_param_k N2
00179             ,   ss_typename_param_k N3
00180             >
00181     associative_container_veneer(N1 n1, N2 n2, N3 n3)
00182         : parent_class_type(n1, n2, n3)
00183     {}
00184     template<   ss_typename_param_k N1
00185             ,   ss_typename_param_k N2
00186             ,   ss_typename_param_k N3
00187             ,   ss_typename_param_k N4
00188             >
00189     associative_container_veneer(N1 n1, N2 n2, N3 n3, N4 n4)
00190         : parent_class_type(n1, n2, n3, n4)
00191     {}
00192     template<   ss_typename_param_k N1
00193             ,   ss_typename_param_k N2
00194             ,   ss_typename_param_k N3
00195             ,   ss_typename_param_k N4
00196             ,   ss_typename_param_k N5
00197             >
00198     associative_container_veneer(N1 n1, N2 n2, N3 n3, N4 n4, N5 n5)
00199         : parent_class_type(n1, n2, n3, n4, n5)
00200     {}
00201 #endif /* !__STLSOFT_COMPILER_IS_DMC */
00202 #endif /* !__STLSOFT_CF_MEMBER_TEMPLATE_FUNCTION_SUPPORT */
00203 
00206     ~associative_container_veneer() stlsoft_throw_0()
00207     {
00208         // Determine the destruction function type, allowing for
00209         // compilers that do not work with member-template functions
00210         typedef select_both <   key_destruction_function_type
00211                             ,   value_destruction_function_type
00212 #ifndef __STLSOFT_CF_MEMBER_TEMPLATE_FUNCTION_SUPPORT
00213                             ,   ss_typename_type_k container_type::iterator::value_type
00214 #endif // __STLSOFT_CF_MEMBER_TEMPLATE_FUNCTION_SUPPORT
00215                             >   destruction_function_t;
00216 
00217         // Simply iterate through the sequence contents and call
00218         // the destruction functions on each item in turn.
00219 
00220         ss_typename_type_k container_type::iterator b   =   container_type::begin();
00221         ss_typename_type_k container_type::iterator e   =   container_type::end();
00222 
00223         for(destruction_function_t fn; b != e; ++b)
00224         {
00225             fn(*b);
00226         }
00227     }
00228 
00235     class_type &operator =(class_type const &rhs)
00236     {
00237         parent_class_type::operator =(rhs);
00238 
00239         return *this;
00240     }
00241 
00242 protected:
00245     void *operator new(size_t )
00246     {
00247         return 0;
00248     }
00251     void operator delete(void *)
00252     {}
00253 };
00254 
00255 /* 
00256 
00257 #ifndef _STLSOFT_NO_NAMESPACE
00258 } // namespace stlsoft
00259 #endif /* _STLSOFT_NO_NAMESPACE */
00260 
00261 /* 
00262 
00263 #endif /* !STLSOFT_INCL_H_STLSOFT_ASSOCIATIVE_CONTAINER_VENEER */
00264 
00265 /* 

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