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.

135 lines
4.2 KiB

  1. /* /////////////////////////////////////////////////////////////////////////
  2. * File: stlsoft/meta/yesno.hpp
  3. *
  4. * Purpose: yes / no classes.
  5. *
  6. * Created: 16th May 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/yesno.hpp
  40. *
  41. * \brief [C++ only] Definition of the stlsoft::yes_type and
  42. * stlsoft::no_type meta boolean "constants"
  43. * (\ref group__library__meta "Template Meta-programming" Library).
  44. */
  45. #ifndef STLSOFT_INCL_STLSOFT_META_HPP_YESNO
  46. #define STLSOFT_INCL_STLSOFT_META_HPP_YESNO
  47. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  48. # define STLSOFT_VER_STLSOFT_META_HPP_YESNO_MAJOR 1
  49. # define STLSOFT_VER_STLSOFT_META_HPP_YESNO_MINOR 3
  50. # define STLSOFT_VER_STLSOFT_META_HPP_YESNO_REVISION 1
  51. # define STLSOFT_VER_STLSOFT_META_HPP_YESNO_EDIT 14
  52. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  53. /* /////////////////////////////////////////////////////////////////////////
  54. * Includes
  55. */
  56. #ifndef STLSOFT_INCL_STLSOFT_H_STLSOFT
  57. # include <stlsoft/stlsoft.h>
  58. #endif /* !STLSOFT_INCL_STLSOFT_H_STLSOFT */
  59. /* /////////////////////////////////////////////////////////////////////////
  60. * Namespace
  61. */
  62. #ifndef _STLSOFT_NO_NAMESPACE
  63. namespace stlsoft
  64. {
  65. #endif /* _STLSOFT_NO_NAMESPACE */
  66. /* /////////////////////////////////////////////////////////////////////////
  67. * Classes
  68. */
  69. /** \brief Meta boolean 'yes' type, which acts as a complement to the
  70. * \link stlsoft::no_type no_type\endlink.
  71. *
  72. * \ingroup group__library__meta
  73. */
  74. struct yes_type
  75. {
  76. char ar[32];
  77. };
  78. /** \brief Meta boolean 'no' type, which acts as a complement to the
  79. * \link stlsoft::yes_type yes_type\endlink.
  80. *
  81. * \ingroup group__library__meta
  82. */
  83. struct no_type
  84. {
  85. char ar[1];
  86. };
  87. /** \brief A type which translates a boolean (integral zero / non-zero)
  88. * value into the appropriate type (no_type / yes_type).
  89. *
  90. * \ingroup group__library__meta
  91. */
  92. template <ss_bool_t B>
  93. struct value_to_yesno_type
  94. {
  95. enum { value = 1 };
  96. typedef yes_type type;
  97. };
  98. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  99. STLSOFT_TEMPLATE_SPECIALISATION
  100. struct value_to_yesno_type<0>
  101. {
  102. enum { value = 0 };
  103. typedef no_type type;
  104. };
  105. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  106. /* ////////////////////////////////////////////////////////////////////// */
  107. #ifndef _STLSOFT_NO_NAMESPACE
  108. } // namespace stlsoft
  109. #endif /* _STLSOFT_NO_NAMESPACE */
  110. /* ////////////////////////////////////////////////////////////////////// */
  111. #endif /* !STLSOFT_INCL_STLSOFT_META_HPP_YESNO */
  112. /* ///////////////////////////// end of file //////////////////////////// */