is_smart_ptr.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. /****************************************************************************
  2. **
  3. ** https://www.qxorm.com/
  4. ** Copyright (C) 2013 Lionel Marty (contact@qxorm.com)
  5. **
  6. ** This file is part of the QxOrm library
  7. **
  8. ** This software is provided 'as-is', without any express or implied
  9. ** warranty. In no event will the authors be held liable for any
  10. ** damages arising from the use of this software
  11. **
  12. ** Commercial Usage
  13. ** Licensees holding valid commercial QxOrm licenses may use this file in
  14. ** accordance with the commercial license agreement provided with the
  15. ** Software or, alternatively, in accordance with the terms contained in
  16. ** a written agreement between you and Lionel Marty
  17. **
  18. ** GNU General Public License Usage
  19. ** Alternatively, this file may be used under the terms of the GNU
  20. ** General Public License version 3.0 as published by the Free Software
  21. ** Foundation and appearing in the file 'license.gpl3.txt' included in the
  22. ** packaging of this file. Please review the following information to
  23. ** ensure the GNU General Public License version 3.0 requirements will be
  24. ** met : http://www.gnu.org/copyleft/gpl.html
  25. **
  26. ** If you are unsure which license is appropriate for your use, or
  27. ** if you have questions regarding the use of this file, please contact :
  28. ** contact@qxorm.com
  29. **
  30. ****************************************************************************/
  31. #ifndef _QX_IS_SMART_PTR_H_
  32. #define _QX_IS_SMART_PTR_H_
  33. #ifdef _MSC_VER
  34. #pragma once
  35. #endif
  36. /*!
  37. * \file is_smart_ptr.h
  38. * \author Lionel Marty
  39. * \ingroup QxTraits
  40. * \brief qx::trait::is_smart_ptr<T>::value : return true if T is a smart-pointer of boost, Qt or QxOrm libraries, otherwise return false
  41. */
  42. #include <QxTraits/is_boost_intrusive_ptr.h>
  43. #include <QxTraits/is_boost_scoped_ptr.h>
  44. #include <QxTraits/is_boost_shared_ptr.h>
  45. #include <QxTraits/is_boost_weak_ptr.h>
  46. #include <QxTraits/is_qt_shared_data_ptr.h>
  47. #include <QxTraits/is_qt_scoped_ptr.h>
  48. #include <QxTraits/is_qt_shared_ptr.h>
  49. #include <QxTraits/is_qt_weak_ptr.h>
  50. #include <QxTraits/is_qx_dao_ptr.h>
  51. #include <QxTraits/is_std_unique_ptr.h>
  52. #include <QxTraits/is_std_shared_ptr.h>
  53. #include <QxTraits/is_std_weak_ptr.h>
  54. namespace qx {
  55. namespace trait {
  56. /*!
  57. * \ingroup QxTraits
  58. * \brief qx::trait::is_smart_ptr<T>::value : return true if T is a smart-pointer of boost, Qt or QxOrm libraries, otherwise return false
  59. */
  60. template <typename T>
  61. struct is_smart_ptr : public std::false_type { ; };
  62. #ifdef _QX_ENABLE_BOOST
  63. template <typename T>
  64. struct is_smart_ptr< boost::shared_ptr<T> > : public std::true_type { ; };
  65. template <typename T>
  66. struct is_smart_ptr< boost::shared_ptr<T> & > : public std::true_type { ; };
  67. template <typename T>
  68. struct is_smart_ptr< const boost::shared_ptr<T> > : public std::true_type { ; };
  69. template <typename T>
  70. struct is_smart_ptr< const boost::shared_ptr<T> & > : public std::true_type { ; };
  71. template <typename T>
  72. struct is_smart_ptr< boost::intrusive_ptr<T> > : public std::true_type { ; };
  73. template <typename T>
  74. struct is_smart_ptr< boost::intrusive_ptr<T> & > : public std::true_type { ; };
  75. template <typename T>
  76. struct is_smart_ptr< const boost::intrusive_ptr<T> > : public std::true_type { ; };
  77. template <typename T>
  78. struct is_smart_ptr< const boost::intrusive_ptr<T> & > : public std::true_type { ; };
  79. template <typename T>
  80. struct is_smart_ptr< boost::scoped_ptr<T> > : public std::true_type { ; };
  81. template <typename T>
  82. struct is_smart_ptr< boost::scoped_ptr<T> & > : public std::true_type { ; };
  83. template <typename T>
  84. struct is_smart_ptr< const boost::scoped_ptr<T> > : public std::true_type { ; };
  85. template <typename T>
  86. struct is_smart_ptr< const boost::scoped_ptr<T> & > : public std::true_type { ; };
  87. template <typename T>
  88. struct is_smart_ptr< boost::weak_ptr<T> > : public std::true_type { ; };
  89. template <typename T>
  90. struct is_smart_ptr< boost::weak_ptr<T> & > : public std::true_type { ; };
  91. template <typename T>
  92. struct is_smart_ptr< const boost::weak_ptr<T> > : public std::true_type { ; };
  93. template <typename T>
  94. struct is_smart_ptr< const boost::weak_ptr<T> & > : public std::true_type { ; };
  95. #endif // _QX_ENABLE_BOOST
  96. #if (QT_VERSION >= 0x040600)
  97. template <typename T>
  98. struct is_smart_ptr< QScopedPointer<T> > : public std::true_type { ; };
  99. template <typename T>
  100. struct is_smart_ptr< QScopedPointer<T> & > : public std::true_type { ; };
  101. template <typename T>
  102. struct is_smart_ptr< const QScopedPointer<T> > : public std::true_type { ; };
  103. template <typename T>
  104. struct is_smart_ptr< const QScopedPointer<T> & > : public std::true_type { ; };
  105. #endif // (QT_VERSION >= 0x040600)
  106. template <typename T>
  107. struct is_smart_ptr< QSharedDataPointer<T> > : public std::true_type { ; };
  108. template <typename T>
  109. struct is_smart_ptr< QSharedDataPointer<T> & > : public std::true_type { ; };
  110. template <typename T>
  111. struct is_smart_ptr< const QSharedDataPointer<T> > : public std::true_type { ; };
  112. template <typename T>
  113. struct is_smart_ptr< const QSharedDataPointer<T> & > : public std::true_type { ; };
  114. template <typename T>
  115. struct is_smart_ptr< QSharedPointer<T> > : public std::true_type { ; };
  116. template <typename T>
  117. struct is_smart_ptr< QSharedPointer<T> & > : public std::true_type { ; };
  118. template <typename T>
  119. struct is_smart_ptr< const QSharedPointer<T> > : public std::true_type { ; };
  120. template <typename T>
  121. struct is_smart_ptr< const QSharedPointer<T> & > : public std::true_type { ; };
  122. template <typename T>
  123. struct is_smart_ptr< QWeakPointer<T> > : public std::true_type { ; };
  124. template <typename T>
  125. struct is_smart_ptr< QWeakPointer<T> & > : public std::true_type { ; };
  126. template <typename T>
  127. struct is_smart_ptr< const QWeakPointer<T> > : public std::true_type { ; };
  128. template <typename T>
  129. struct is_smart_ptr< const QWeakPointer<T> & > : public std::true_type { ; };
  130. template <typename T>
  131. struct is_smart_ptr< qx::dao::ptr<T> > : public std::true_type { ; };
  132. template <typename T>
  133. struct is_smart_ptr< qx::dao::ptr<T> & > : public std::true_type { ; };
  134. template <typename T>
  135. struct is_smart_ptr< const qx::dao::ptr<T> > : public std::true_type { ; };
  136. template <typename T>
  137. struct is_smart_ptr< const qx::dao::ptr<T> & > : public std::true_type { ; };
  138. template <typename T>
  139. struct is_smart_ptr< std::shared_ptr<T> > : public std::true_type { ; };
  140. template <typename T>
  141. struct is_smart_ptr< std::shared_ptr<T> & > : public std::true_type { ; };
  142. template <typename T>
  143. struct is_smart_ptr< const std::shared_ptr<T> > : public std::true_type { ; };
  144. template <typename T>
  145. struct is_smart_ptr< const std::shared_ptr<T> & > : public std::true_type { ; };
  146. template <typename T>
  147. struct is_smart_ptr< std::unique_ptr<T> > : public std::true_type { ; };
  148. template <typename T>
  149. struct is_smart_ptr< std::unique_ptr<T> & > : public std::true_type { ; };
  150. template <typename T>
  151. struct is_smart_ptr< const std::unique_ptr<T> > : public std::true_type { ; };
  152. template <typename T>
  153. struct is_smart_ptr< const std::unique_ptr<T> & > : public std::true_type { ; };
  154. template <typename T>
  155. struct is_smart_ptr< std::weak_ptr<T> > : public std::true_type { ; };
  156. template <typename T>
  157. struct is_smart_ptr< std::weak_ptr<T> & > : public std::true_type { ; };
  158. template <typename T>
  159. struct is_smart_ptr< const std::weak_ptr<T> > : public std::true_type { ; };
  160. template <typename T>
  161. struct is_smart_ptr< const std::weak_ptr<T> & > : public std::true_type { ; };
  162. } // namespace trait
  163. } // namespace qx
  164. #endif // _QX_IS_SMART_PTR_H_