QxOrm 1.4.9
C++ Object Relational Mapping library
Loading...
Searching...
No Matches
is_container_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_CONTAINER_BASE_OF_H_
33#define _QX_IS_CONTAINER_BASE_OF_H_
34
35#ifdef _MSC_VER
36#pragma once
37#endif
38
40
41#define qx_container_base_of_test_0() (sizeof(qx::trait::is_container_base_of<B, D>::removeContainer(b, d)) == sizeof(char))
42#define qx_container_base_of_test_1() (sizeof(qx::trait::is_container_base_of<B, D>::removeContainer((* b_std_vector), d)) == sizeof(char))
43#define qx_container_base_of_test_2() (sizeof(qx::trait::is_container_base_of<B, D>::removeContainer((* b_std_list), d)) == sizeof(char))
44#define qx_container_base_of_test_3() (sizeof(qx::trait::is_container_base_of<B, D>::removeContainer((* b_std_set), d)) == sizeof(char))
45#define qx_container_base_of_test_4() (sizeof(qx::trait::is_container_base_of<B, D>::removeContainer((* b_qt_vector), d)) == sizeof(char))
46#define qx_container_base_of_test_5() (sizeof(qx::trait::is_container_base_of<B, D>::removeContainer((* b_qt_list), d)) == sizeof(char))
47#define qx_container_base_of_test_6() (sizeof(qx::trait::is_container_base_of<B, D>::removeContainer((* b_qt_set), d)) == sizeof(char))
48#define qx_container_base_of_test_7() (sizeof(qx::trait::is_container_base_of<B, D>::removeContainer((* b_qt_linked_list), d)) == sizeof(char))
49#define qx_container_base_of_test_8() (sizeof(qx::trait::is_container_base_of<B, D>::removeContainer((* b_boost_unordered_set), d)) == sizeof(char))
50#define qx_container_base_of_test_9() (sizeof(qx::trait::is_container_base_of<B, D>::removeContainer((* b_boost_unordered_multi_set), d)) == sizeof(char))
51
52#define qx_container_base_of_test_10() (sizeof(qx::trait::is_container_base_of<B, D>::removeContainer((* b_std_unordered_set), d)) == sizeof(char))
53#define qx_container_base_of_test_11() (sizeof(qx::trait::is_container_base_of<B, D>::removeContainer((* b_std_unordered_multi_set), d)) == sizeof(char))
54
55#define qx_container_base_of_all_test() \
56qx_container_base_of_test_1() || qx_container_base_of_test_2() || qx_container_base_of_test_3() || \
57qx_container_base_of_test_4() || qx_container_base_of_test_5() || qx_container_base_of_test_6() || \
58qx_container_base_of_test_7() || qx_container_base_of_test_8() || qx_container_base_of_test_9() || \
59qx_container_base_of_test_10() || qx_container_base_of_test_11()
60
61namespace qx {
62namespace trait {
63
64template <typename B, typename D>
66{
67
68private:
69
70 template <typename V, typename W>
71 static typename std::conditional<std::is_base_of<V, W>::value, char, int>::type removeContainer(const std::vector<V> &, const std::vector<W> &);
72
73 template <typename V, typename W>
74 static typename std::conditional<std::is_base_of<V, W>::value, char, int>::type removeContainer(const std::list<V> &, const std::list<W> &);
75
76 template <typename V, typename W>
77 static typename std::conditional<std::is_base_of<V, W>::value, char, int>::type removeContainer(const std::set<V> &, const std::set<W> &);
78
79#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
80 template <typename V, typename W>
81 static typename std::conditional<std::is_base_of<V, W>::value, char, int>::type removeContainer(const QVector<V> &, const QVector<W> &);
82#endif // (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
83
84 template <typename V, typename W>
85 static typename std::conditional<std::is_base_of<V, W>::value, char, int>::type removeContainer(const QList<V> &, const QList<W> &);
86
87 template <typename V, typename W>
88 static typename std::conditional<std::is_base_of<V, W>::value, char, int>::type removeContainer(const QSet<V> &, const QSet<W> &);
89
90#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0))
91 template <typename V, typename W>
92 static typename std::conditional<std::is_base_of<V, W>::value, char, int>::type removeContainer(const QLinkedList<V> &, const QLinkedList<W> &);
93#endif // (QT_VERSION < QT_VERSION_CHECK(5, 15, 0))
94
95#ifdef _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 removeContainer(const boost::unordered_set<V> &, const boost::unordered_set<W> &);
99
100 template <typename V, typename W>
101 static typename std::conditional<std::is_base_of<V, W>::value, char, int>::type removeContainer(const boost::unordered_multiset<V> &, const boost::unordered_multiset<W> &);
102
103#endif // _QX_ENABLE_BOOST
104
105 template <typename V, typename W>
106 static typename std::conditional<std::is_base_of<V, W>::value, char, int>::type removeContainer(const std::unordered_set<V> &, const std::unordered_set<W> &);
107
108 template <typename V, typename W>
109 static typename std::conditional<std::is_base_of<V, W>::value, char, int>::type removeContainer(const std::unordered_multiset<V> &, const std::unordered_multiset<W> &);
110
111 static int removeContainer(...);
112 static B b;
113 static D d;
114
115 static std::vector<B> * b_std_vector;
116 static std::list<B> * b_std_list;
117 static std::set<B> * b_std_set;
118 static QVector<B> * b_qt_vector;
119 static QList<B> * b_qt_list;
120 static QSet<B> * b_qt_set;
121
122#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0))
123 static QLinkedList<B> * b_qt_linked_list;
124#endif // (QT_VERSION < QT_VERSION_CHECK(5, 15, 0))
125
126#ifdef _QX_ENABLE_BOOST
127
128 static boost::unordered_set<B> * b_boost_unordered_set;
129 static boost::unordered_multiset<B> * b_boost_unordered_multi_set;
130
131#endif // _QX_ENABLE_BOOST
132
133 static std::unordered_set<B> * b_std_unordered_set;
134 static std::unordered_multiset<B> * b_std_unordered_multi_set;
135
140
141public:
142
144
145 typedef typename std::conditional<qx::trait::is_container_base_of<B, D>::value, std::true_type, std::false_type>::type type;
146
147};
148
149} // namespace trait
150} // namespace qx
151
152#endif // _QX_IS_CONTAINER_BASE_OF_H_
std::conditional< qx::trait::is_container_base_of< B, D >::value, std::true_type, std::false_type >::type type
static std::conditional< std::is_base_of< V, W >::value, char, int >::type removeContainer(const QList< V > &, const QList< W > &)
static std::conditional< std::is_base_of< V, W >::value, char, int >::type removeContainer(const boost::unordered_set< V > &, const boost::unordered_set< W > &)
static std::conditional< std::is_base_of< V, W >::value, char, int >::type removeContainer(const boost::unordered_multiset< V > &, const boost::unordered_multiset< W > &)
static std::conditional< std::is_base_of< V, W >::value, char, int >::type removeContainer(const std::set< V > &, const std::set< W > &)
static std::conditional< std::is_base_of< V, W >::value, char, int >::type removeContainer(const std::unordered_multiset< V > &, const std::unordered_multiset< W > &)
static std::conditional< std::is_base_of< V, W >::value, char, int >::type removeContainer(const std::vector< V > &, const std::vector< W > &)
static boost::unordered_set< B > * b_boost_unordered_set
static std::unordered_multiset< B > * b_std_unordered_multi_set
static boost::unordered_multiset< B > * b_boost_unordered_multi_set
static std::unordered_set< B > * b_std_unordered_set
static std::conditional< std::is_base_of< V, W >::value, char, int >::type removeContainer(const QSet< V > &, const QSet< W > &)
static std::vector< B > * b_std_vector
static std::conditional< std::is_base_of< V, W >::value, char, int >::type removeContainer(const std::unordered_set< V > &, const std::unordered_set< W > &)
static std::conditional< std::is_base_of< V, W >::value, char, int >::type removeContainer(const std::list< V > &, const std::list< W > &)
qx::trait::is_container<T>::value : return true if T is a container from stl, boost,...
#define qx_container_base_of_test_0()
#define qx_container_base_of_all_test()
Root namespace for all QxOrm library features.
qx::trait::is_container<T>::value : return true if T is a container from stl, boost,...