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.

137 lines
5.1 KiB

  1. /* /////////////////////////////////////////////////////////////////////////
  2. * File: stlsoft/meta/util/meta_.hpp (originally MTBase.h, ::SynesisStl)
  3. *
  4. * Purpose: Basic meta programming constructs.
  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/meta/util/meta_.hpp
  40. *
  41. * \brief [C++ only] Definition of basic meta programming constructs
  42. * (\ref group__library__meta "Template Meta-programming" Library).
  43. */
  44. #ifndef STLSOFT_INCL_STLSOFT_META_UTIL_HPP_META_
  45. #define STLSOFT_INCL_STLSOFT_META_UTIL_HPP_META_
  46. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  47. # define STLSOFT_VER_STLSOFT_META_UTIL_HPP_META__MAJOR 4
  48. # define STLSOFT_VER_STLSOFT_META_UTIL_HPP_META__MINOR 1
  49. # define STLSOFT_VER_STLSOFT_META_UTIL_HPP_META__REVISION 1
  50. # define STLSOFT_VER_STLSOFT_META_UTIL_HPP_META__EDIT 128
  51. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  52. /* /////////////////////////////////////////////////////////////////////////
  53. * Includes
  54. */
  55. #ifndef STLSOFT_INCL_STLSOFT_H_STLSOFT
  56. # include <stlsoft/stlsoft.h>
  57. #endif /* !STLSOFT_INCL_STLSOFT_H_STLSOFT */
  58. /* /////////////////////////////////////////////////////////////////////////
  59. * Namespace
  60. */
  61. #ifndef _STLSOFT_NO_NAMESPACE
  62. namespace stlsoft
  63. {
  64. #endif /* _STLSOFT_NO_NAMESPACE */
  65. /* /////////////////////////////////////////////////////////////////////////
  66. * Macros
  67. */
  68. /** \brief \def STLSOFT_GEN_TRAIT_SPECIALISATION
  69. * \ingroup group__project__stlsoft__code_modification_macros
  70. *
  71. * \brief Used to define a specialisation of a traits type
  72. *
  73. */
  74. #define STLSOFT_GEN_TRAIT_SPECIALISATION(TR, T, V) \
  75. \
  76. STLSOFT_TEMPLATE_SPECIALISATION \
  77. struct TR<T> \
  78. { \
  79. enum { value = V }; \
  80. };
  81. /** \brief \def STLSOFT_GEN_TRAIT_SPECIALISATION_WITH_TYPE
  82. * \ingroup group__project__stlsoft__code_modification_macros
  83. *
  84. * \brief Used to define a specialisation of a traits type that contains a member type
  85. *
  86. */
  87. #define STLSOFT_GEN_TRAIT_SPECIALISATION_WITH_TYPE(TR, T, V, MT) \
  88. \
  89. STLSOFT_TEMPLATE_SPECIALISATION \
  90. struct TR<T> \
  91. { \
  92. enum { value = V }; \
  93. \
  94. typedef MT type; \
  95. };
  96. /* /////////////////////////////////////////////////////////////////////////
  97. * Typedefs and basic support types
  98. */
  99. #if ( !defined(STLSOFT_COMPILER_IS_MSVC) || \
  100. _MSC_VER != 1200) || \
  101. defined(STLSOFT_META_ALLOW_INT_TO_TYPE)
  102. /** \brief Converts compile time constants to type.
  103. *
  104. * \ingroup group__library__meta
  105. */
  106. template <int N>
  107. struct int_to_type
  108. {};
  109. #endif /* _MSC_VER == 1200 */
  110. /* ////////////////////////////////////////////////////////////////////// */
  111. #ifndef _STLSOFT_NO_NAMESPACE
  112. } // namespace stlsoft
  113. #endif /* _STLSOFT_NO_NAMESPACE */
  114. /* ////////////////////////////////////////////////////////////////////// */
  115. #endif /* !STLSOFT_INCL_STLSOFT_META_UTIL_HPP_META_ */
  116. /* ///////////////////////////// end of file //////////////////////////// */