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.

183 lines
7.8 KiB

  1. /* /////////////////////////////////////////////////////////////////////////
  2. * File: stlsoft/meta/member_traits.hpp
  3. *
  4. * Purpose: An amalgamation of meta traits that's been pending reification
  5. * for too long.
  6. *
  7. * Created: 11th October 2004
  8. * Updated: 10th August 2009
  9. *
  10. * Home: http://stlsoft.org/
  11. *
  12. * Copyright (c) 2004-2009, Matthew Wilson and Synesis Software
  13. * All rights reserved.
  14. *
  15. * Redistribution and use in source and binary forms, with or without
  16. * modification, are permitted provided that the following conditions are met:
  17. *
  18. * - Redistributions of source code must retain the above copyright notice, this
  19. * list of conditions and the following disclaimer.
  20. * - Redistributions in binary form must reproduce the above copyright notice,
  21. * this list of conditions and the following disclaimer in the documentation
  22. * and/or other materials provided with the distribution.
  23. * - Neither the name(s) of Matthew Wilson and Synesis Software nor the names of
  24. * any contributors may be used to endorse or promote products derived from
  25. * this software without specific prior written permission.
  26. *
  27. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  28. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  29. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  30. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  31. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  32. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  33. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  34. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  35. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  36. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  37. * POSSIBILITY OF SUCH DAMAGE.
  38. *
  39. * ////////////////////////////////////////////////////////////////////// */
  40. /** \file stlsoft/meta/member_traits.hpp
  41. *
  42. * \brief [C++ only] Definition of the stlsoft::member_traits component
  43. * (\ref group__library__meta "Template Meta-programming" Library).
  44. */
  45. // An amalgamation of meta traits that's been pending reification for too long.
  46. //
  47. // It defines the member_traits template, which is used to detect the members
  48. // supported by a given type.
  49. #ifndef STLSOFT_INCL_STLSOFT_META_HPP_MEMBER_TRAITS
  50. #define STLSOFT_INCL_STLSOFT_META_HPP_MEMBER_TRAITS
  51. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  52. # define STLSOFT_VER_STLSOFT_META_HPP_MEMBER_TRAITS_MAJOR 2
  53. # define STLSOFT_VER_STLSOFT_META_HPP_MEMBER_TRAITS_MINOR 1
  54. # define STLSOFT_VER_STLSOFT_META_HPP_MEMBER_TRAITS_REVISION 1
  55. # define STLSOFT_VER_STLSOFT_META_HPP_MEMBER_TRAITS_EDIT 37
  56. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  57. /* /////////////////////////////////////////////////////////////////////////
  58. * Auto-generation and compatibility
  59. */
  60. /*
  61. [Incompatibilies-start]
  62. STLSOFT_COMPILER_IS_BORLAND:
  63. STLSOFT_COMPILER_IS_DMC: __DMC__ < 0x0845
  64. STLSOFT_COMPILER_IS_MSVC: _MSC_VER < 1310
  65. STLSOFT_COMPILER_IS_WATCOM:
  66. [Incompatibilies-end]
  67. */
  68. /* /////////////////////////////////////////////////////////////////////////
  69. * Includes
  70. */
  71. #ifndef STLSOFT_INCL_STLSOFT_H_STLSOFT
  72. # include <stlsoft/stlsoft.h>
  73. #endif /* !STLSOFT_INCL_STLSOFT_H_STLSOFT */
  74. #ifndef STLSOFT_INCL_STLSOFT_META_HPP_CAPABILITIES
  75. # include <stlsoft/meta/capabilities.hpp>
  76. #endif /* !STLSOFT_INCL_STLSOFT_META_HPP_CAPABILITIES */
  77. #ifndef STLSOFT_CF_HAS_MEMBER_TYPE_SUPPORTED
  78. # error This file is not compatible with compilers that do not support member type detection
  79. #endif /* !STLSOFT_CF_HAS_MEMBER_TYPE_SUPPORTED */
  80. #ifndef STLSOFT_INCL_STLSOFT_META_HPP_DETECTORS
  81. # include <stlsoft/meta/detectors.hpp>
  82. #endif /* !STLSOFT_INCL_STLSOFT_META_HPP_DETECTORS */
  83. /* /////////////////////////////////////////////////////////////////////////
  84. * Namespace
  85. */
  86. #ifndef _STLSOFT_NO_NAMESPACE
  87. namespace stlsoft
  88. {
  89. #endif /* _STLSOFT_NO_NAMESPACE */
  90. /* /////////////////////////////////////////////////////////////////////////
  91. * Classes
  92. */
  93. /** \brief A structure that can be used to report whether various well-known
  94. * facets of a type are supported
  95. *
  96. * \ingroup group__library__meta
  97. *
  98. *
  99. * member_traits may be used in the compile-time evaluation of whether a given
  100. * type has certain members, as follows:
  101. *
  102. \code
  103. \endcode
  104. */
  105. template<ss_typename_param_k T>
  106. struct member_traits
  107. {
  108. public:
  109. typedef T value_type;
  110. typedef member_traits<T> class_type;
  111. /// \name Member Constants
  112. /// @{
  113. public:
  114. #if defined(STLSOFT_CF_HAS_MEMBER_TYPE_SUPPORTED)
  115. enum { has_member_iterator_category = 0 != has_iterator_category<T>::value /*!< Indicates whether the type has an \c iterator_category member */ };
  116. enum { has_member_value_type = 0 != has_value_type<T>::value /*!< Indicates whether the type has a \c value_type member */ };
  117. enum { has_member_distance_type = 0 != has_distance_type<T>::value /*!< Indicates whether the type has a \c distance_type member */ };
  118. enum { has_member_pointer = 0 != has_pointer<T>::value /*!< Indicates whether the type has a \c pointer member */ };
  119. enum { has_member_pointer_type = 0 != has_pointer_type<T>::value /*!< Indicates whether the type has a \c pointer_type member */ };
  120. enum { has_member_iterator = 0 != has_iterator<T>::value /*!< Indicates whether the type has an \c iterator member */ };
  121. # if !defined(STLSOFT_COMPILER_IS_DMC) || \
  122. __DMC__ >= 0x0845
  123. enum { has_member_const_iterator = 0 != has_const_iterator<T>::value /*!< Indicates whether the type has a \c const_iterator member */ };
  124. # endif /* compiler */
  125. enum { has_member_const_pointer = 0 != has_const_pointer<T>::value /*!< Indicates whether the type has a \c const_pointer member */ };
  126. # if defined(STLSOFT_COMPILER_IS_MWERKS)
  127. enum { has_member_reference = 0 != has_reference<T>::value /*!< Indicates whether the type has a \c reference member */ };
  128. enum { has_member_reference_type = 0 != has_reference_type<T>::value /*!< Indicates whether the type has a \c reference_type member */ };
  129. enum { has_member_const_reference = 0 != has_const_reference<T>::value /*!< Indicates whether the type has a \c const_reference member */ };
  130. # endif /* compiler */
  131. enum { has_member_difference_type = 0 != has_difference_type<T>::value /*!< Indicates whether the type has a \c difference_type member */ };
  132. enum { has_member_key_type = 0 != has_key_type<T>::value /*!< Indicates whether the type has a \c key_type member */ };
  133. enum { has_member_mapped_type = 0 != has_mapped_type<T>::value /*!< Indicates whether the type has a \c mapped_type member */ };
  134. enum { has_member_referent_type = 0 != has_referent_type<T>::value /*!< Indicates whether the type has a \c referent_type member */ };
  135. #endif /* STLSOFT_CF_HAS_MEMBER_TYPE_SUPPORTED */
  136. /// @}
  137. // Not to be implemented
  138. private:
  139. member_traits();
  140. #ifdef STLSOFT_CF_COMPILER_WARNS_NO_PUBLIC_DTOR
  141. protected:
  142. #endif /* STLSOFT_CF_COMPILER_WARNS_NO_PUBLIC_DTOR */
  143. member_traits(class_type const& rhs);
  144. class_type& operator =(class_type const& rhs);
  145. };
  146. /* ////////////////////////////////////////////////////////////////////// */
  147. #ifndef _STLSOFT_NO_NAMESPACE
  148. } // namespace stlsoft
  149. #endif /* _STLSOFT_NO_NAMESPACE */
  150. /* ////////////////////////////////////////////////////////////////////// */
  151. #endif /* !STLSOFT_INCL_STLSOFT_META_HPP_MEMBER_TRAITS */
  152. /* ///////////////////////////// end of file //////////////////////////// */