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.

176 lines
5.0 KiB

  1. /* /////////////////////////////////////////////////////////////////////////
  2. * File: stlsoft/meta/add_qualifier.hpp
  3. *
  4. * Purpose: Adds a const or volatile qualifier to a type.
  5. *
  6. * Created: 30th December 2005
  7. * Updated: 10th August 2009
  8. *
  9. * Home: http://stlsoft.org/
  10. *
  11. * Copyright (c) 2005-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/add_qualifier.hpp
  40. *
  41. * \brief [C++ only] Definition of the stlsoft::add_const,
  42. * stlsoft::add_volatile, stlsoft::add_const_ref and
  43. * stlsoft::add_volatile_ref meta-programming type adjuster components
  44. * (\ref group__library__meta "Template Meta-programming" Library).
  45. */
  46. #ifndef STLSOFT_INCL_STLSOFT_META_HPP_ADD_QUALIFIER
  47. #define STLSOFT_INCL_STLSOFT_META_HPP_ADD_QUALIFIER
  48. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  49. # define STLSOFT_VER_STLSOFT_META_HPP_ADD_QUALIFIER_MAJOR 1
  50. # define STLSOFT_VER_STLSOFT_META_HPP_ADD_QUALIFIER_MINOR 1
  51. # define STLSOFT_VER_STLSOFT_META_HPP_ADD_QUALIFIER_REVISION 2
  52. # define STLSOFT_VER_STLSOFT_META_HPP_ADD_QUALIFIER_EDIT 11
  53. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  54. /* /////////////////////////////////////////////////////////////////////////
  55. * Includes
  56. */
  57. #ifndef STLSOFT_INCL_STLSOFT_H_STLSOFT
  58. # include <stlsoft/stlsoft.h>
  59. #endif /* !STLSOFT_INCL_STLSOFT_H_STLSOFT */
  60. /* /////////////////////////////////////////////////////////////////////////
  61. * Namespace
  62. */
  63. #ifndef _STLSOFT_NO_NAMESPACE
  64. namespace stlsoft
  65. {
  66. #endif /* _STLSOFT_NO_NAMESPACE */
  67. /* /////////////////////////////////////////////////////////////////////////
  68. * Classes
  69. */
  70. /** \brief Adds <code>const</code> qualifier to a type.
  71. *
  72. * \ingroup group__library__meta
  73. */
  74. template <ss_typename_param_k T>
  75. struct add_const
  76. {
  77. typedef const T type;
  78. };
  79. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  80. STLSOFT_TEMPLATE_SPECIALISATION
  81. struct add_const<void>
  82. {
  83. typedef void type;
  84. };
  85. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  86. /** \brief Adds <code>volatile</code> qualifier to a type.
  87. *
  88. * \ingroup group__library__meta
  89. */
  90. template <ss_typename_param_k T>
  91. struct add_volatile
  92. {
  93. typedef volatile T type;
  94. };
  95. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  96. STLSOFT_TEMPLATE_SPECIALISATION
  97. struct add_volatile<void>
  98. {
  99. typedef void type;
  100. };
  101. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  102. /** \brief Adds <code>const&amp;</code> qualifier to a type.
  103. *
  104. * \ingroup group__library__meta
  105. */
  106. template <ss_typename_param_k T>
  107. struct add_const_ref
  108. {
  109. typedef T const& type;
  110. };
  111. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  112. STLSOFT_TEMPLATE_SPECIALISATION
  113. struct add_const_ref<void>
  114. {
  115. typedef void type;
  116. };
  117. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  118. /** \brief Adds <code>volatile&amp;</code> qualifier to a type.
  119. *
  120. * \ingroup group__library__meta
  121. */
  122. template <ss_typename_param_k T>
  123. struct add_volatile_ref
  124. {
  125. typedef volatile T& type;
  126. };
  127. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  128. STLSOFT_TEMPLATE_SPECIALISATION
  129. struct add_volatile_ref<void>
  130. {
  131. typedef void type;
  132. };
  133. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  134. /* ////////////////////////////////////////////////////////////////////// */
  135. #ifndef _STLSOFT_NO_NAMESPACE
  136. } // namespace stlsoft
  137. #endif /* _STLSOFT_NO_NAMESPACE */
  138. /* ////////////////////////////////////////////////////////////////////// */
  139. #endif /* !STLSOFT_INCL_STLSOFT_META_HPP_ADD_QUALIFIER */
  140. /* ///////////////////////////// end of file //////////////////////////// */