You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

360 lines
13 KiB

  1. /* /////////////////////////////////////////////////////////////////////////
  2. * File: stlsoft/obsolete/meta.hpp (originally MTBase.h, ::SynesisStl)
  3. *
  4. * Purpose: Meta programming primitives.
  5. *
  6. * Created: 19th November 1998
  7. * Updated: 10th August 2009
  8. *
  9. * Home: http://stlsoft.org/
  10. *
  11. * Copyright (c) 1998-2009, Matthew Wilson and Synesis Software
  12. * All rights reserved.
  13. *
  14. * Redistribution and use in source and binary forms, with or without
  15. * modification, are permitted provided that the following conditions are met:
  16. *
  17. * - Redistributions of source code must retain the above copyright notice, this
  18. * list of conditions and the following disclaimer.
  19. * - Redistributions in binary form must reproduce the above copyright notice,
  20. * this list of conditions and the following disclaimer in the documentation
  21. * and/or other materials provided with the distribution.
  22. * - Neither the name(s) of Matthew Wilson and Synesis Software nor the names of
  23. * any contributors may be used to endorse or promote products derived from
  24. * this software without specific prior written permission.
  25. *
  26. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  27. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  28. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  29. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  30. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  31. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  32. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  33. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  34. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  35. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  36. * POSSIBILITY OF SUCH DAMAGE.
  37. *
  38. * ////////////////////////////////////////////////////////////////////// */
  39. /** \file stlsoft/obsolete/meta.hpp
  40. *
  41. * \brief [C++ only; OBSOLETE] Contains obsolete Meta programming primitives
  42. * (\ref group__library__meta "Template Meta-programming" Library).
  43. */
  44. #ifndef STLSOFT_INCL_STLSOFT_OBSOLETE_HPP_META
  45. #define STLSOFT_INCL_STLSOFT_OBSOLETE_HPP_META
  46. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  47. # define STLSOFT_VER_STLSOFT_OBSOLETE_HPP_META_MAJOR 4
  48. # define STLSOFT_VER_STLSOFT_OBSOLETE_HPP_META_MINOR 0
  49. # define STLSOFT_VER_STLSOFT_OBSOLETE_HPP_META_REVISION 3
  50. # define STLSOFT_VER_STLSOFT_OBSOLETE_HPP_META_EDIT 133
  51. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  52. /* /////////////////////////////////////////////////////////////////////////
  53. * Compatibility
  54. */
  55. /*
  56. [Incompatibilies-start]
  57. STLSOFT_COMPILER_IS_MSVC: _MSC_VER<1200
  58. [Incompatibilies-end]
  59. */
  60. /* /////////////////////////////////////////////////////////////////////////
  61. * Includes
  62. */
  63. #ifndef STLSOFT_INCL_STLSOFT_H_STLSOFT
  64. # include <stlsoft/stlsoft.h>
  65. #endif /* !STLSOFT_INCL_STLSOFT_H_STLSOFT */
  66. #if defined(STLSOFT_COMPILER_IS_MSVC) && \
  67. _MSC_VER < 1200
  68. # error stlsoft/obsolete/meta.hpp is not compatible with Visual C++ 5.0 or earlier
  69. #endif /* compiler */
  70. #ifndef STLSOFT_INCL_STLSOFT_META_HPP_CAPABILITIES
  71. # include <stlsoft/meta/capabilities.hpp>
  72. #endif /* !STLSOFT_INCL_STLSOFT_META_HPP_CAPABILITIES */
  73. #ifndef STLSOFT_INCL_STLSOFT_META_UTIL_HPP_META_
  74. # include <stlsoft/meta/util/meta_.hpp>
  75. #endif /* !STLSOFT_INCL_STLSOFT_META_UTIL_HPP_META_ */
  76. #ifndef STLSOFT_INCL_STLSOFT_META_HPP_YESNO
  77. # include <stlsoft/meta/yesno.hpp>
  78. #endif /* !STLSOFT_INCL_STLSOFT_META_HPP_YESNO */
  79. #ifndef STLSOFT_INCL_STLSOFT_META_HPP_IS_ARRAY_TYPE
  80. # include <stlsoft/meta/is_array_type.hpp>
  81. #endif /* !STLSOFT_INCL_STLSOFT_META_HPP_IS_ARRAY_TYPE */
  82. #ifndef STLSOFT_INCL_STLSOFT_META_HPP_IS_BOOL_TYPE
  83. # include <stlsoft/meta/is_bool_type.hpp>
  84. #endif /* !STLSOFT_INCL_STLSOFT_META_HPP_IS_BOOL_TYPE */
  85. #ifndef STLSOFT_INCL_STLSOFT_META_HPP_IS_CHARACTER_TYPE
  86. # include <stlsoft/meta/is_character_type.hpp>
  87. #endif /* !STLSOFT_INCL_STLSOFT_META_HPP_IS_CHARACTER_TYPE */
  88. #ifndef STLSOFT_INCL_STLSOFT_META_HPP_IS_CLASS_TYPE
  89. # include <stlsoft/meta/is_class_type.hpp>
  90. #endif /* !STLSOFT_INCL_STLSOFT_META_HPP_IS_CLASS_TYPE */
  91. #ifndef STLSOFT_INCL_STLSOFT_META_HPP_IS_COMPOUND_TYPE
  92. # include <stlsoft/meta/is_compound_type.hpp>
  93. #endif /* !STLSOFT_INCL_STLSOFT_META_HPP_IS_COMPOUND_TYPE */
  94. #ifndef STLSOFT_INCL_STLSOFT_META_HPP_IS_CONST_TYPE
  95. # include <stlsoft/meta/is_const_type.hpp>
  96. #endif /* !STLSOFT_INCL_STLSOFT_META_HPP_IS_CONST_TYPE */
  97. #ifndef STLSOFT_INCL_STLSOFT_META_HPP_IS_FLOATING_POINT_TYPE
  98. # include <stlsoft/meta/is_floating_point_type.hpp>
  99. #endif /* !STLSOFT_INCL_STLSOFT_META_HPP_IS_FLOATING_POINT_TYPE */
  100. #ifndef STLSOFT_INCL_STLSOFT_META_HPP_IS_FUNCTION_POINTER_TYPE
  101. # include <stlsoft/meta/is_function_pointer_type.hpp>
  102. #endif /* !STLSOFT_INCL_STLSOFT_META_HPP_IS_FUNCTION_POINTER_TYPE */
  103. #ifndef STLSOFT_INCL_STLSOFT_META_HPP_IS_FUNDAMENTAL_TYPE
  104. # include <stlsoft/meta/is_fundamental_type.hpp>
  105. #endif /* !STLSOFT_INCL_STLSOFT_META_HPP_IS_FUNDAMENTAL_TYPE */
  106. #ifndef STLSOFT_INCL_STLSOFT_META_HPP_IS_INTEGRAL_TYPE
  107. # include <stlsoft/meta/is_integral_type.hpp>
  108. #endif /* !STLSOFT_INCL_STLSOFT_META_HPP_IS_INTEGRAL_TYPE */
  109. #ifndef STLSOFT_INCL_STLSOFT_META_HPP_IS_NUMERIC_TYPE
  110. # include <stlsoft/meta/is_numeric_type.hpp>
  111. #endif /* !STLSOFT_INCL_STLSOFT_META_HPP_IS_NUMERIC_TYPE */
  112. #ifndef STLSOFT_INCL_STLSOFT_META_HPP_IS_POINTER_TYPE
  113. # include <stlsoft/meta/is_pointer_type.hpp>
  114. #endif /* !STLSOFT_INCL_STLSOFT_META_HPP_IS_POINTER_TYPE */
  115. #ifndef STLSOFT_INCL_STLSOFT_META_HPP_IS_SAME_TYPE
  116. # include <stlsoft/meta/is_same_type.hpp>
  117. #endif /* !STLSOFT_INCL_STLSOFT_META_HPP_IS_SAME_TYPE */
  118. #ifndef STLSOFT_INCL_STLSOFT_META_HPP_IS_SIGNED_TYPE
  119. # include <stlsoft/meta/is_signed_type.hpp>
  120. #endif /* !STLSOFT_INCL_STLSOFT_META_HPP_IS_SIGNED_TYPE */
  121. #ifndef STLSOFT_INCL_STLSOFT_META_HPP_IS_VOID_TYPE
  122. # include <stlsoft/meta/is_void_type.hpp>
  123. #endif /* !STLSOFT_INCL_STLSOFT_META_HPP_IS_VOID_TYPE */
  124. #ifndef STLSOFT_INCL_STLSOFT_META_HPP_IS_VOLATILE_TYPE
  125. # include <stlsoft/meta/is_volatile_type.hpp>
  126. #endif /* !STLSOFT_INCL_STLSOFT_META_HPP_IS_VOLATILE_TYPE */
  127. #ifdef STLSOFT_CF_HAS_MEMBER_TYPE_SUPPORTED
  128. # ifndef STLSOFT_INCL_STLSOFT_META_DETECTOR_HPP_HAS_CONST_ITERATOR
  129. # include <stlsoft/meta/detector/has_const_iterator.hpp>
  130. # endif /* !STLSOFT_INCL_STLSOFT_META_DETECTOR_HPP_HAS_CONST_ITERATOR */
  131. # ifndef STLSOFT_INCL_STLSOFT_META_DETECTOR_HPP_HAS_CONST_POINTER
  132. # include <stlsoft/meta/detector/has_const_pointer.hpp>
  133. # endif /* !STLSOFT_INCL_STLSOFT_META_DETECTOR_HPP_HAS_CONST_POINTER */
  134. # ifndef STLSOFT_INCL_STLSOFT_META_DETECTOR_HPP_HAS_CONST_REFERENCE
  135. # include <stlsoft/meta/detector/has_const_reference.hpp>
  136. # endif /* !STLSOFT_INCL_STLSOFT_META_DETECTOR_HPP_HAS_CONST_REFERENCE */
  137. # ifndef STLSOFT_INCL_STLSOFT_META_DETECTOR_HPP_HAS_DIFFERENCE_TYPE
  138. # include <stlsoft/meta/detector/has_difference_type.hpp>
  139. # endif /* !STLSOFT_INCL_STLSOFT_META_DETECTOR_HPP_HAS_DIFFERENCE_TYPE */
  140. # ifndef STLSOFT_INCL_STLSOFT_META_DETECTOR_HPP_HAS_DISTANCE_TYPE
  141. # include <stlsoft/meta/detector/has_distance_type.hpp>
  142. # endif /* !STLSOFT_INCL_STLSOFT_META_DETECTOR_HPP_HAS_DISTANCE_TYPE */
  143. # ifndef STLSOFT_INCL_STLSOFT_META_DETECTOR_HPP_HAS_ITERATOR
  144. # include <stlsoft/meta/detector/has_iterator.hpp>
  145. # endif /* !STLSOFT_INCL_STLSOFT_META_DETECTOR_HPP_HAS_ITERATOR */
  146. # ifndef STLSOFT_INCL_STLSOFT_META_DETECTOR_HPP_HAS_ITERATOR_CATEGORY
  147. # include <stlsoft/meta/detector/has_iterator_category.hpp>
  148. # endif /* !STLSOFT_INCL_STLSOFT_META_DETECTOR_HPP_HAS_ITERATOR_CATEGORY */
  149. # ifndef STLSOFT_INCL_STLSOFT_META_DETECTOR_HPP_HAS_KEY_TYPE
  150. # include <stlsoft/meta/detector/has_key_type.hpp>
  151. # endif /* !STLSOFT_INCL_STLSOFT_META_DETECTOR_HPP_HAS_KEY_TYPE */
  152. # ifndef STLSOFT_INCL_STLSOFT_META_DETECTOR_HPP_HAS_MAPPED_TYPE
  153. # include <stlsoft/meta/detector/has_mapped_type.hpp>
  154. # endif /* !STLSOFT_INCL_STLSOFT_META_DETECTOR_HPP_HAS_MAPPED_TYPE */
  155. # ifndef STLSOFT_INCL_STLSOFT_META_DETECTOR_HPP_HAS_POINTER
  156. # include <stlsoft/meta/detector/has_pointer.hpp>
  157. # endif /* !STLSOFT_INCL_STLSOFT_META_DETECTOR_HPP_HAS_POINTER */
  158. # ifndef STLSOFT_INCL_STLSOFT_META_DETECTOR_HPP_HAS_POINTER_TYPE
  159. # include <stlsoft/meta/detector/has_pointer_type.hpp>
  160. # endif /* !STLSOFT_INCL_STLSOFT_META_DETECTOR_HPP_HAS_POINTER_TYPE */
  161. # ifndef STLSOFT_INCL_STLSOFT_META_DETECTOR_HPP_HAS_REFERENCE
  162. # include <stlsoft/meta/detector/has_reference.hpp>
  163. # endif /* !STLSOFT_INCL_STLSOFT_META_DETECTOR_HPP_HAS_REFERENCE */
  164. # ifndef STLSOFT_INCL_STLSOFT_META_DETECTOR_HPP_HAS_REFERENCE_TYPE
  165. # include <stlsoft/meta/detector/has_reference_type.hpp>
  166. # endif /* !STLSOFT_INCL_STLSOFT_META_DETECTOR_HPP_HAS_REFERENCE_TYPE */
  167. # ifndef STLSOFT_INCL_STLSOFT_META_DETECTOR_HPP_HAS_REFERENT_TYPE
  168. # include <stlsoft/meta/detector/has_referent_type.hpp>
  169. # endif /* !STLSOFT_INCL_STLSOFT_META_DETECTOR_HPP_HAS_REFERENT_TYPE */
  170. # ifndef STLSOFT_INCL_STLSOFT_META_DETECTOR_HPP_HAS_VALUE_TYPE
  171. # include <stlsoft/meta/detector/has_value_type.hpp>
  172. # endif /* !STLSOFT_INCL_STLSOFT_META_DETECTOR_HPP_HAS_VALUE_TYPE */
  173. #endif /* STLSOFT_CF_HAS_MEMBER_TYPE_SUPPORTED */
  174. #ifndef STLSOFT_INCL_STLSOFT_META_HPP_N_TYPES
  175. # include <stlsoft/meta/n_types.hpp>
  176. #endif /* !STLSOFT_INCL_STLSOFT_META_HPP_N_TYPES */
  177. #ifndef STLSOFT_INCL_STLSOFT_META_HPP_SELECT_FIRST_TYPE_IF
  178. # include <stlsoft/meta/select_first_type_if.hpp>
  179. #endif /* !STLSOFT_INCL_STLSOFT_META_HPP_SELECT_FIRST_TYPE_IF */
  180. #ifndef STLSOFT_INCL_STLSOFT_META_HPP_SIZEOF
  181. # include <stlsoft/meta/size_of.hpp>
  182. #endif /* !STLSOFT_INCL_STLSOFT_META_HPP_SIZEOF */
  183. /* /////////////////////////////////////////////////////////////////////////
  184. * Namespace
  185. */
  186. #ifndef _STLSOFT_NO_NAMESPACE
  187. namespace stlsoft
  188. {
  189. #endif /* _STLSOFT_NO_NAMESPACE */
  190. /* /////////////////////////////////////////////////////////////////////////
  191. * Tests
  192. */
  193. // is_convertible_to_pointer
  194. //
  195. /** \brief This test determines whether the given type is convertible to a pointer
  196. * type
  197. *
  198. * \ingroup group__library__meta
  199. *
  200. * \deprecated
  201. *
  202. */
  203. template <ss_typename_param_k T>
  204. struct is_convertible_to_pointer
  205. {
  206. };
  207. // is_convertible_to_bool
  208. //
  209. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  210. template <ss_typename_param_k T>
  211. struct convertible_index
  212. {
  213. // typedef <size_type> type;
  214. };
  215. STLSOFT_TEMPLATE_SPECIALISATION
  216. struct convertible_index<int>
  217. {
  218. typedef size_type<2> type;
  219. };
  220. STLSOFT_TEMPLATE_SPECIALISATION
  221. struct convertible_index<unsigned>
  222. {
  223. typedef size_type<3> type;
  224. };
  225. #ifdef STLSOFT_CF_NATIVE_BOOL_SUPPORT
  226. STLSOFT_TEMPLATE_SPECIALISATION
  227. struct convertible_index<bool>
  228. {
  229. typedef size_type<4> type;
  230. };
  231. #endif /* STLSOFT_CF_NATIVE_BOOL_SUPPORT */
  232. STLSOFT_TEMPLATE_SPECIALISATION
  233. struct convertible_index<void*>
  234. {
  235. typedef size_type<5> type;
  236. };
  237. STLSOFT_TEMPLATE_SPECIALISATION
  238. struct convertible_index<long double>
  239. {
  240. typedef size_type<6> type;
  241. };
  242. size_type<1> convertible_index_function(...);
  243. //convertible_index<int>::type convertible_index_function(int );
  244. //convertible_index<unsigned>::type convertible_index_function(unsigned );
  245. # ifdef STLSOFT_COMPILER_IS_MSVC
  246. convertible_index<int>::type convertible_index_function(int );
  247. convertible_index<int>::type convertible_index_function(unsigned int );
  248. convertible_index<int>::type convertible_index_function(long );
  249. convertible_index<int>::type convertible_index_function(unsigned long );
  250. convertible_index<long double>::type convertible_index_function(double );
  251. convertible_index<long double>::type convertible_index_function(long double );
  252. # endif /* compiler */
  253. # ifdef STLSOFT_CF_NATIVE_BOOL_SUPPORT
  254. convertible_index<bool>::type convertible_index_function(bool );
  255. # endif /* STLSOFT_CF_NATIVE_BOOL_SUPPORT */
  256. convertible_index<void*>::type convertible_index_function(void const volatile* );
  257. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  258. /** \brief This test determines whether the given type is convertible to a pointer
  259. * type
  260. *
  261. * \ingroup group__library__meta
  262. *
  263. * \deprecated
  264. */
  265. template <ss_typename_param_k T>
  266. struct is_convertible_to_bool
  267. {
  268. enum { value = sizeof(convertible_index_function(*static_cast<T*>(0))) == sizeof(convertible_index<bool>::type) };
  269. };
  270. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  271. STLSOFT_TEMPLATE_SPECIALISATION
  272. struct is_convertible_to_bool<void>
  273. {
  274. enum { value = 0 };
  275. };
  276. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  277. /** \brief Obsolete form of stlsoft::is_const_type
  278. *
  279. * \ingroup group__library__meta
  280. *
  281. * \deprecated Use stlsoft::is_const_type instead.
  282. */
  283. template <ss_typename_param_k T>
  284. struct is_const
  285. {
  286. enum { value = is_const_type<T>::value };
  287. };
  288. /** \brief Obsolete form of stlsoft::is_volatile_type
  289. *
  290. * \ingroup group__library__meta
  291. *
  292. * \deprecated Use stlsoft::is_volatile_type instead.
  293. */
  294. template <ss_typename_param_k T>
  295. struct is_volatile
  296. {
  297. enum { value = is_volatile_type<T>::value };
  298. };
  299. /** \brief Obsolete form of \link stlsoft::is_void_type is_void_type\endlink.
  300. *
  301. * \ingroup group__library__meta
  302. *
  303. * \deprecated Use \link stlsoft::is_void_type is_void_type\endlink instead.
  304. */
  305. template <ss_typename_param_k T>
  306. struct is_void
  307. {
  308. enum { value = is_void_type<T>::value };
  309. };
  310. /* ////////////////////////////////////////////////////////////////////// */
  311. #ifndef _STLSOFT_NO_NAMESPACE
  312. } /* namespace stlsoft */
  313. #endif /* _STLSOFT_NO_NAMESPACE */
  314. /* ////////////////////////////////////////////////////////////////////// */
  315. #endif /* !STLSOFT_INCL_STLSOFT_OBSOLETE_HPP_META */
  316. /* ///////////////////////////// end of file //////////////////////////// */