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

Go to the documentation of this file.
00001 /* 
00002  * File:        stlsoft_any_caster.h
00003  *
00004  * Purpose:     A dangerous, but sometimes necessary, tool for handling bad
00005  *              libraries.
00006  *
00007  * Created:     12th May 2004
00008  * Updated:     11th September 2004
00009  *
00010  * Home:        http://stlsoft.org/
00011  *
00012  * Copyright (c) 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_ANY_CASTER
00047 #define STLSOFT_INCL_H_STLSOFT_ANY_CASTER
00048 
00049 #ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION
00050 # define STLSOFT_VER_H_STLSOFT_ANY_CASTER_MAJOR     2
00051 # define STLSOFT_VER_H_STLSOFT_ANY_CASTER_MINOR     0
00052 # define STLSOFT_VER_H_STLSOFT_ANY_CASTER_REVISION  1
00053 # define STLSOFT_VER_H_STLSOFT_ANY_CASTER_EDIT      14
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  * Classes
00075  */
00076 
00078 template <ss_size_t N>
00079 struct any_caster_invalid_type
00080 {
00081     typedef any_caster_invalid_type<N>  class_type;
00082 
00083 #if defined(__STLSOFT_COMPILER_IS_GCC)
00084 protected:
00085 #else /* ? compiler */
00086 private:
00087 #endif /* compiler */
00088     any_caster_invalid_type();
00089     any_caster_invalid_type(class_type const &);
00090 };
00091 
00097 template<   typename    T
00098         ,   typename    T1
00099         ,   typename    T2
00100         ,   typename    T3  =   any_caster_invalid_type<3>*
00101         ,   typename    T4  =   any_caster_invalid_type<4>*
00102         ,   typename    T5  =   any_caster_invalid_type<5>*
00103         ,   typename    T6  =   any_caster_invalid_type<6>*
00104         ,   typename    T7  =   any_caster_invalid_type<7>*
00105         ,   typename    T8  =   any_caster_invalid_type<8>*
00106         >
00107 union any_caster
00108 {
00109     typedef any_caster<T, T1, T2, T3, T4, T5, T6, T7, T8>   class_type;
00110 
00113 public:
00115     ss_explicit_k any_caster(T t)
00116     {
00117         this->t = t;
00118     }
00120 
00123 public:
00124     operator T1 () const
00125     {
00126         return t1;
00127     }
00128     operator T2 () const
00129     {
00130         return t2;
00131     }
00132     operator T3 () const
00133     {
00134         return t3;
00135     }
00136     operator T4 () const
00137     {
00138         return t4;
00139     }
00140     operator T5 () const
00141     {
00142         return t5;
00143     }
00144     operator T6 () const
00145     {
00146         return t6;
00147     }
00148     operator T7 () const
00149     {
00150         return t7;
00151     }
00152     operator T8 () const
00153     {
00154         return t8;
00155     }
00157 
00158 private:
00159     T   t;
00160     T1  t1;
00161     T2  t2;
00162     T3  t3;
00163     T4  t4;
00164     T5  t5;
00165     T6  t6;
00166     T7  t7;
00167     T8  t8;
00168 
00169 // Not to be implemented
00170 private:
00171     any_caster(class_type const &rhs);
00172     class_type &operator =(class_type const &rhs);
00173 };
00174 
00175 /* 
00176 
00177 #ifndef _STLSOFT_NO_NAMESPACE
00178 } // namespace stlsoft
00179 #endif /* _STLSOFT_NO_NAMESPACE */
00180 
00181 /* 
00182 
00183 #endif /* !STLSOFT_INCL_H_STLSOFT_ANY_CASTER */
00184 
00185 /* 

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