QxOrm 1.4.9
C++ Object Relational Mapping library
Loading...
Searching...
No Matches
is_smart_ptr_base_of.h
Go to the documentation of this file.
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
32#ifndef _QX_IS_SMART_PTR_BASE_OF_H_
33#define _QX_IS_SMART_PTR_BASE_OF_H_
34
35#ifdef _MSC_VER
36#pragma once
37#endif
38
47
48#define qx_smart_ptr_base_of_test_0() (sizeof(qx::trait::is_smart_ptr_base_of<B, D>::removeSmartPtr(b, d)) == sizeof(char))
49#define qx_smart_ptr_base_of_test_1() (sizeof(qx::trait::is_smart_ptr_base_of<B, D>::removeSmartPtr((* b_boost_scoped_ptr), d)) == sizeof(char))
50#define qx_smart_ptr_base_of_test_2() (sizeof(qx::trait::is_smart_ptr_base_of<B, D>::removeSmartPtr((* b_boost_shared_ptr), d)) == sizeof(char))
51#define qx_smart_ptr_base_of_test_3() (sizeof(qx::trait::is_smart_ptr_base_of<B, D>::removeSmartPtr((* b_boost_weak_ptr), d)) == sizeof(char))
52#define qx_smart_ptr_base_of_test_4() (sizeof(qx::trait::is_smart_ptr_base_of<B, D>::removeSmartPtr((* b_boost_intrusive_ptr), d)) == sizeof(char))
53#define qx_smart_ptr_base_of_test_5() (sizeof(qx::trait::is_smart_ptr_base_of<B, D>::removeSmartPtr((* b_qt_shared_data_ptr), d)) == sizeof(char))
54#define qx_smart_ptr_base_of_test_6() (sizeof(qx::trait::is_smart_ptr_base_of<B, D>::removeSmartPtr((* b_qt_shared_ptr), d)) == sizeof(char))
55#define qx_smart_ptr_base_of_test_7() (sizeof(qx::trait::is_smart_ptr_base_of<B, D>::removeSmartPtr((* b_qt_weak_ptr), d)) == sizeof(char))
56#define qx_smart_ptr_base_of_test_8() (sizeof(qx::trait::is_smart_ptr_base_of<B, D>::removeSmartPtr((* b_qx_dao_ptr), d)) == sizeof(char))
57
58#define qx_smart_ptr_base_of_test_9() (sizeof(qx::trait::is_smart_ptr_base_of<B, D>::removeSmartPtr((* b_std_unique_ptr), d)) == sizeof(char))
59#define qx_smart_ptr_base_of_test_10() (sizeof(qx::trait::is_smart_ptr_base_of<B, D>::removeSmartPtr((* b_std_shared_ptr), d)) == sizeof(char))
60#define qx_smart_ptr_base_of_test_11() (sizeof(qx::trait::is_smart_ptr_base_of<B, D>::removeSmartPtr((* b_std_weak_ptr), d)) == sizeof(char))
61
62#define qx_smart_ptr_base_of_all_test() \
63qx_smart_ptr_base_of_test_1() || qx_smart_ptr_base_of_test_2() || qx_smart_ptr_base_of_test_3() || \
64qx_smart_ptr_base_of_test_4() || qx_smart_ptr_base_of_test_5() || qx_smart_ptr_base_of_test_6() || \
65qx_smart_ptr_base_of_test_7() || qx_smart_ptr_base_of_test_8() || qx_smart_ptr_base_of_test_9() || \
66qx_smart_ptr_base_of_test_10() || qx_smart_ptr_base_of_test_11()
67
68namespace qx {
69namespace trait {
70
75template <typename B, typename D>
77{
78
79private:
80
81#ifdef _QX_ENABLE_BOOST
82
83 template <typename V, typename W>
84 static typename std::conditional<std::is_base_of<V, W>::value, char, int>::type removeSmartPtr(const boost::scoped_ptr<V> &, const boost::scoped_ptr<W> &);
85
86 template <typename V, typename W>
87 static typename std::conditional<std::is_base_of<V, W>::value, char, int>::type removeSmartPtr(const boost::shared_ptr<V> &, const boost::shared_ptr<W> &);
88
89 template <typename V, typename W>
90 static typename std::conditional<std::is_base_of<V, W>::value, char, int>::type removeSmartPtr(const boost::weak_ptr<V> &, const boost::weak_ptr<W> &);
91
92 template <typename V, typename W>
93 static typename std::conditional<std::is_base_of<V, W>::value, char, int>::type removeSmartPtr(const boost::intrusive_ptr<V> &, const boost::intrusive_ptr<W> &);
94
95#endif // _QX_ENABLE_BOOST
96
97 template <typename V, typename W>
98 static typename std::conditional<std::is_base_of<V, W>::value, char, int>::type removeSmartPtr(const QSharedDataPointer<V> &, const QSharedDataPointer<W> &);
99
100 template <typename V, typename W>
101 static typename std::conditional<std::is_base_of<V, W>::value, char, int>::type removeSmartPtr(const QSharedPointer<V> &, const QSharedPointer<W> &);
102
103 template <typename V, typename W>
104 static typename std::conditional<std::is_base_of<V, W>::value, char, int>::type removeSmartPtr(const QWeakPointer<V> &, const QWeakPointer<W> &);
105
106 template <typename V, typename W>
107 static typename std::conditional<std::is_base_of<V, W>::value, char, int>::type removeSmartPtr(const qx::dao::ptr<V> &, const qx::dao::ptr<W> &);
108
109 template <typename V, typename W>
110 static typename std::conditional<std::is_base_of<V, W>::value, char, int>::type removeSmartPtr(const std::unique_ptr<V> &, const std::unique_ptr<W> &);
111
112 template <typename V, typename W>
113 static typename std::conditional<std::is_base_of<V, W>::value, char, int>::type removeSmartPtr(const std::shared_ptr<V> &, const std::shared_ptr<W> &);
114
115 template <typename V, typename W>
116 static typename std::conditional<std::is_base_of<V, W>::value, char, int>::type removeSmartPtr(const std::weak_ptr<V> &, const std::weak_ptr<W> &);
117
118 static int removeSmartPtr(...);
119 static B b;
120 static D d;
121
122#ifdef _QX_ENABLE_BOOST
123
124 static boost::scoped_ptr<B> * b_boost_scoped_ptr;
125 static boost::shared_ptr<B> * b_boost_shared_ptr;
126 static boost::weak_ptr<B> * b_boost_weak_ptr;
127 static boost::intrusive_ptr<B> * b_boost_intrusive_ptr;
128
129#endif // _QX_ENABLE_BOOST
130
131 static QSharedDataPointer<B> * b_qt_shared_data_ptr;
132 static QSharedPointer<B> * b_qt_shared_ptr;
133 static QWeakPointer<B> * b_qt_weak_ptr;
135
136 static std::unique_ptr<B> * b_std_unique_ptr;
137 static std::shared_ptr<B> * b_std_shared_ptr;
138 static std::weak_ptr<B> * b_std_weak_ptr;
139
144
145public:
146
148
149 typedef typename std::conditional<qx::trait::is_smart_ptr_base_of<B, D>::value, std::true_type, std::false_type>::type type;
150
151};
152
153} // namespace trait
154} // namespace qx
155
156#endif // _QX_IS_SMART_PTR_BASE_OF_H_
qx::dao::ptr<T> : provide a classic smart-pointer (like boost::shared_ptr<T> or QSharedPointer<T>) wi...
qx::trait::is_smart_ptr_base_of<B, D>::value : return true if B and D are smart-pointers of boost,...
static std::conditional< std::is_base_of< V, W >::value, char, int >::type removeSmartPtr(const std::shared_ptr< V > &, const std::shared_ptr< W > &)
static std::unique_ptr< B > * b_std_unique_ptr
static std::conditional< std::is_base_of< V, W >::value, char, int >::type removeSmartPtr(const QWeakPointer< V > &, const QWeakPointer< W > &)
static QSharedPointer< B > * b_qt_shared_ptr
static std::conditional< std::is_base_of< V, W >::value, char, int >::type removeSmartPtr(const boost::scoped_ptr< V > &, const boost::scoped_ptr< W > &)
static std::conditional< std::is_base_of< V, W >::value, char, int >::type removeSmartPtr(const QSharedPointer< V > &, const QSharedPointer< W > &)
static std::conditional< std::is_base_of< V, W >::value, char, int >::type removeSmartPtr(const boost::shared_ptr< V > &, const boost::shared_ptr< W > &)
static boost::scoped_ptr< B > * b_boost_scoped_ptr
static std::conditional< std::is_base_of< V, W >::value, char, int >::type removeSmartPtr(const boost::weak_ptr< V > &, const boost::weak_ptr< W > &)
static std::conditional< std::is_base_of< V, W >::value, char, int >::type removeSmartPtr(const std::weak_ptr< V > &, const std::weak_ptr< W > &)
static QSharedDataPointer< B > * b_qt_shared_data_ptr
static std::conditional< std::is_base_of< V, W >::value, char, int >::type removeSmartPtr(const std::unique_ptr< V > &, const std::unique_ptr< W > &)
static std::conditional< std::is_base_of< V, W >::value, char, int >::type removeSmartPtr(const qx::dao::ptr< V > &, const qx::dao::ptr< W > &)
std::conditional< qx::trait::is_smart_ptr_base_of< B, D >::value, std::true_type, std::false_type >::type type
static boost::weak_ptr< B > * b_boost_weak_ptr
static std::conditional< std::is_base_of< V, W >::value, char, int >::type removeSmartPtr(const boost::intrusive_ptr< V > &, const boost::intrusive_ptr< W > &)
static boost::intrusive_ptr< B > * b_boost_intrusive_ptr
static boost::shared_ptr< B > * b_boost_shared_ptr
static std::shared_ptr< B > * b_std_shared_ptr
static std::weak_ptr< B > * b_std_weak_ptr
static QWeakPointer< B > * b_qt_weak_ptr
static std::conditional< std::is_base_of< V, W >::value, char, int >::type removeSmartPtr(const QSharedDataPointer< V > &, const QSharedDataPointer< W > &)
static qx::dao::ptr< B > * b_qx_dao_ptr
qx::trait::is_smart_ptr<T>::value : return true if T is a smart-pointer of boost, Qt or QxOrm librari...
#define qx_smart_ptr_base_of_test_0()
#define qx_smart_ptr_base_of_all_test()
Root namespace for all QxOrm library features.
qx::trait::is_smart_ptr<T>::value : return true if T is a smart-pointer of boost, Qt or QxOrm librari...