00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00047 #ifndef STLSOFT_INCL_STLSOFT_CONVERSION_HPP_EXPLICIT_CAST
00048 #define STLSOFT_INCL_STLSOFT_CONVERSION_HPP_EXPLICIT_CAST
00049
00050 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00051 # define STLSOFT_VER_STLSOFT_CONVERSION_HPP_EXPLICIT_CAST_MAJOR 4
00052 # define STLSOFT_VER_STLSOFT_CONVERSION_HPP_EXPLICIT_CAST_MINOR 0
00053 # define STLSOFT_VER_STLSOFT_CONVERSION_HPP_EXPLICIT_CAST_REVISION 1
00054 # define STLSOFT_VER_STLSOFT_CONVERSION_HPP_EXPLICIT_CAST_EDIT 36
00055 #endif
00056
00057
00058
00059
00060
00061 #ifndef STLSOFT_INCL_STLSOFT_H_STLSOFT
00062 # include <stlsoft/stlsoft.h>
00063 #endif
00064
00065
00066
00067
00068
00069 #ifndef _STLSOFT_NO_NAMESPACE
00070 namespace stlsoft
00071 {
00072 #endif
00073
00074
00075
00076
00077
00078
00079
00086 template <ss_typename_param_k T>
00087 class explicit_cast
00088 {
00089 public:
00090 typedef T value_type;
00091 typedef explicit_cast<T> class_type;
00092
00093
00094 public:
00095 explicit_cast(T t)
00096 : m_t(t)
00097 {}
00098
00099 #ifndef STLSOFT_CF_TEMPLATE_PARTIAL_SPECIALISATION_SUPPORT
00100
00101
00102 ~explicit_cast() stlsoft_throw_0()
00103 {
00104 union must_be_basic_type
00105 {
00106 int i;
00107 T t;
00108 };
00109 }
00110 #endif
00111
00112
00113 public:
00114 operator value_type () const
00115 {
00116 return m_t;
00117 }
00118
00119
00120 private:
00121 T m_t;
00122 };
00123
00124 #ifdef STLSOFT_CF_TEMPLATE_PARTIAL_SPECIALISATION_SUPPORT
00125
00133 template <ss_typename_param_k T>
00134 class explicit_cast<T &>
00135 {
00136 public:
00137 typedef T value_type;
00138 typedef explicit_cast<T> class_type;
00139
00140
00141 private:
00142 explicit_cast(T &);
00143
00144
00145 private:
00146 operator T & ();
00147
00148 # if defined(STLSOFT_COMPILER_IS_GCC)
00149 public: static void f() {}
00150 # endif
00151 };
00152
00153 # ifdef _STLSOFT_EXPLICIT_CAST_FORCE_ALLOW_REFERENCE_TO_CONST_UDT
00154
00155 # if defined(STLSOFT_COMPILER_IS_BORLAND) || \
00156 defined(STLSOFT_COMPILER_IS_DMC) || \
00157 defined(STLSOFT_COMPILER_IS_GCC) || \
00158 ( defined(STLSOFT_COMPILER_IS_MSVC) && \
00159 _MSC_VER == 1310) || \
00160 defined(STLSOFT_COMPILER_IS_WATCOM)
00161
00162 # elif defined(STLSOFT_COMPILER_IS_INTEL) || \
00163 ( defined(STLSOFT_COMPILER_IS_MSVC) && \
00164 _MSC_VER != 1310)
00165
00166 # error The current compiler does not properly implement it
00167 # else
00168
00169 # error The current compiler has not been assessed as to whether it correctly translates explicit_cast for references to non-const
00170 # endif
00171
00172 template <ss_typename_param_k T>
00173 class explicit_cast<T const&>
00174 {
00175 public:
00176 typedef T value_type;
00177 typedef explicit_cast<T> class_type;
00178
00179
00180 public:
00181 explicit_cast(T const& t)
00182 : m_t(t)
00183 {}
00184
00185
00186 public:
00187 operator T const& () const
00188 {
00189 return m_t;
00190 }
00191
00192
00193 private:
00194 T const& m_t;
00195 };
00196 # else
00197
00198 # ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00199 # if defined(STLSOFT_COMPILER_IS_MSVC)
00200 # if _MSC_VER >= 1200
00201 # pragma warning(push)
00202 # endif
00203 # pragma warning(disable : 4512)
00204 # endif
00205 # ifndef STLSOFT_INCL_STLSOFT_INTERNAL_HPP_EXPLICIT_CAST_SPECIALISATIONS
00206 # include <stlsoft/conversion/internal/explicit_cast_specialisations.hpp>
00207 # endif
00208 # if defined(STLSOFT_COMPILER_IS_MSVC)
00209 # if _MSC_VER >= 1200
00210 # pragma warning(pop)
00211 # else
00212 # pragma warning(disable : 4512)
00213 # endif
00214 # endif
00215 # endif
00216
00217 # endif
00218
00224 template <ss_typename_param_k T>
00225 class explicit_cast<T *>
00226 {
00227 public:
00228 typedef T value_type;
00229 typedef explicit_cast<T> class_type;
00230
00231
00232 public:
00233 explicit_cast(T *t)
00234 : m_t(t)
00235 {}
00236
00237
00238 public:
00239 operator T * ()
00240 {
00241 return m_t;
00242 }
00243
00244
00245 private:
00246 T *m_t;
00247 };
00248
00249 # ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00250
00251 template <ss_typename_param_k T>
00252 class explicit_cast<T const*>
00253 {
00254 public:
00255 typedef T value_type;
00256 typedef explicit_cast<T> class_type;
00257
00258
00259 public:
00260 explicit_cast(T const* t)
00261 : m_t(t)
00262 {}
00263
00264
00265 public:
00266 operator T const* () const
00267 {
00268 return m_t;
00269 }
00270
00271
00272 private:
00273 T const* m_t;
00274 };
00275
00276 # endif
00277
00278 #endif // STLSOFT_CF_TEMPLATE_PARTIAL_SPECIALISATION_SUPPORT
00279
00280
00281
00282 #ifndef _STLSOFT_NO_NAMESPACE
00283 }
00284 #endif
00285
00286
00287
00288 #endif
00289
00290