/work/install-coverage/include/opencv4/opencv2/flann/any.h
Line | Count | Source (jump to first uncovered line) |
1 | | #ifndef OPENCV_FLANN_ANY_H_ |
2 | | #define OPENCV_FLANN_ANY_H_ |
3 | | /* |
4 | | * (C) Copyright Christopher Diggins 2005-2011 |
5 | | * (C) Copyright Pablo Aguilar 2005 |
6 | | * (C) Copyright Kevlin Henney 2001 |
7 | | * |
8 | | * Distributed under the Boost Software License, Version 1.0. (See |
9 | | * accompanying file LICENSE_1_0.txt or copy at |
10 | | * http://www.boost.org/LICENSE_1_0.txt |
11 | | * |
12 | | * Adapted for FLANN by Marius Muja |
13 | | */ |
14 | | |
15 | | //! @cond IGNORED |
16 | | |
17 | | #include "defines.h" |
18 | | #include <stdexcept> |
19 | | #include <ostream> |
20 | | #include <typeinfo> |
21 | | |
22 | | #include "opencv2/core/cvdef.h" |
23 | | #include "opencv2/core/utility.hpp" |
24 | | |
25 | | namespace cvflann |
26 | | { |
27 | | |
28 | | namespace anyimpl |
29 | | { |
30 | | |
31 | | struct bad_any_cast : public std::exception |
32 | | { |
33 | | bad_any_cast() = default; |
34 | | |
35 | | bad_any_cast(const char* src, const char* dst) |
36 | 0 | : message_(cv::format("cvflann::bad_any_cast(from %s to %s)", src, dst)) {} |
37 | | |
38 | | |
39 | | const char* what() const noexcept override |
40 | 0 | { |
41 | 0 | return message_.c_str(); |
42 | 0 | } |
43 | | |
44 | | private: |
45 | | std::string message_{"cvflann::bad_any_cast"}; |
46 | | }; |
47 | | |
48 | | #ifndef CV_THROW_IF_TYPE_MISMATCH |
49 | | #define CV_THROW_IF_TYPE_MISMATCH(src_type_info, dst_type_info) \ |
50 | | if ((src_type_info) != (dst_type_info)) \ |
51 | | throw cvflann::anyimpl::bad_any_cast((src_type_info).name(), \ |
52 | | (dst_type_info).name()) |
53 | | #endif |
54 | | |
55 | | struct empty_any |
56 | | { |
57 | | }; |
58 | | |
59 | | inline std::ostream& operator <<(std::ostream& out, const empty_any&) |
60 | 0 | { |
61 | 0 | out << "[empty_any]"; |
62 | 0 | return out; |
63 | 0 | } |
64 | | |
65 | | struct base_any_policy |
66 | | { |
67 | | virtual void static_delete(void** x) = 0; |
68 | | virtual void copy_from_value(void const* src, void** dest) = 0; |
69 | | virtual void clone(void* const* src, void** dest) = 0; |
70 | | virtual void move(void* const* src, void** dest) = 0; |
71 | | virtual void* get_value(void** src) = 0; |
72 | | virtual const void* get_value(void* const * src) = 0; |
73 | | virtual ::size_t get_size() = 0; |
74 | | virtual const std::type_info& type() = 0; |
75 | | virtual void print(std::ostream& out, void* const* src) = 0; |
76 | 0 | virtual ~base_any_policy() {} |
77 | | }; |
78 | | |
79 | | template<typename T> |
80 | | struct typed_base_any_policy : base_any_policy |
81 | | { |
82 | 0 | virtual ::size_t get_size() CV_OVERRIDE { return sizeof(T); } Unexecuted instantiation: cvflann::anyimpl::typed_base_any_policy<cvflann::anyimpl::empty_any>::get_size() Unexecuted instantiation: cvflann::anyimpl::typed_base_any_policy<char const*>::get_size() Unexecuted instantiation: cvflann::anyimpl::typed_base_any_policy<int>::get_size() Unexecuted instantiation: cvflann::anyimpl::typed_base_any_policy<float>::get_size() Unexecuted instantiation: cvflann::anyimpl::typed_base_any_policy<bool>::get_size() Unexecuted instantiation: cvflann::anyimpl::typed_base_any_policy<cvflann::flann_algorithm_t>::get_size() Unexecuted instantiation: cvflann::anyimpl::typed_base_any_policy<cvflann::flann_centers_init_t>::get_size() Unexecuted instantiation: cvflann::anyimpl::typed_base_any_policy<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::get_size() |
83 | 0 | virtual const std::type_info& type() CV_OVERRIDE { return typeid(T); } Unexecuted instantiation: cvflann::anyimpl::typed_base_any_policy<cvflann::anyimpl::empty_any>::type() Unexecuted instantiation: cvflann::anyimpl::typed_base_any_policy<char const*>::type() Unexecuted instantiation: cvflann::anyimpl::typed_base_any_policy<int>::type() Unexecuted instantiation: cvflann::anyimpl::typed_base_any_policy<float>::type() Unexecuted instantiation: cvflann::anyimpl::typed_base_any_policy<bool>::type() Unexecuted instantiation: cvflann::anyimpl::typed_base_any_policy<cvflann::flann_algorithm_t>::type() Unexecuted instantiation: cvflann::anyimpl::typed_base_any_policy<cvflann::flann_centers_init_t>::type() Unexecuted instantiation: cvflann::anyimpl::typed_base_any_policy<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::type() |
84 | | |
85 | | }; |
86 | | |
87 | | template<typename T> |
88 | | struct small_any_policy CV_FINAL : typed_base_any_policy<T> |
89 | | { |
90 | 0 | virtual void static_delete(void**) CV_OVERRIDE { } Unexecuted instantiation: cvflann::anyimpl::small_any_policy<char const*>::static_delete(void**) Unexecuted instantiation: cvflann::anyimpl::small_any_policy<int>::static_delete(void**) Unexecuted instantiation: cvflann::anyimpl::small_any_policy<float>::static_delete(void**) Unexecuted instantiation: cvflann::anyimpl::small_any_policy<bool>::static_delete(void**) |
91 | | virtual void copy_from_value(void const* src, void** dest) CV_OVERRIDE |
92 | 0 | { |
93 | 0 | new (dest) T(* reinterpret_cast<T const*>(src)); |
94 | 0 | } Unexecuted instantiation: cvflann::anyimpl::small_any_policy<char const*>::copy_from_value(void const*, void**) Unexecuted instantiation: cvflann::anyimpl::small_any_policy<int>::copy_from_value(void const*, void**) Unexecuted instantiation: cvflann::anyimpl::small_any_policy<float>::copy_from_value(void const*, void**) Unexecuted instantiation: cvflann::anyimpl::small_any_policy<bool>::copy_from_value(void const*, void**) |
95 | 0 | virtual void clone(void* const* src, void** dest) CV_OVERRIDE { *dest = *src; } Unexecuted instantiation: cvflann::anyimpl::small_any_policy<char const*>::clone(void* const*, void**) Unexecuted instantiation: cvflann::anyimpl::small_any_policy<int>::clone(void* const*, void**) Unexecuted instantiation: cvflann::anyimpl::small_any_policy<float>::clone(void* const*, void**) Unexecuted instantiation: cvflann::anyimpl::small_any_policy<bool>::clone(void* const*, void**) |
96 | 0 | virtual void move(void* const* src, void** dest) CV_OVERRIDE { *dest = *src; } Unexecuted instantiation: cvflann::anyimpl::small_any_policy<char const*>::move(void* const*, void**) Unexecuted instantiation: cvflann::anyimpl::small_any_policy<int>::move(void* const*, void**) Unexecuted instantiation: cvflann::anyimpl::small_any_policy<float>::move(void* const*, void**) Unexecuted instantiation: cvflann::anyimpl::small_any_policy<bool>::move(void* const*, void**) |
97 | 0 | virtual void* get_value(void** src) CV_OVERRIDE { return reinterpret_cast<void*>(src); } Unexecuted instantiation: cvflann::anyimpl::small_any_policy<char const*>::get_value(void**) Unexecuted instantiation: cvflann::anyimpl::small_any_policy<int>::get_value(void**) Unexecuted instantiation: cvflann::anyimpl::small_any_policy<float>::get_value(void**) Unexecuted instantiation: cvflann::anyimpl::small_any_policy<bool>::get_value(void**) |
98 | 0 | virtual const void* get_value(void* const * src) CV_OVERRIDE { return reinterpret_cast<const void*>(src); } Unexecuted instantiation: cvflann::anyimpl::small_any_policy<char const*>::get_value(void* const*) Unexecuted instantiation: cvflann::anyimpl::small_any_policy<int>::get_value(void* const*) Unexecuted instantiation: cvflann::anyimpl::small_any_policy<float>::get_value(void* const*) Unexecuted instantiation: cvflann::anyimpl::small_any_policy<bool>::get_value(void* const*) |
99 | 0 | virtual void print(std::ostream& out, void* const* src) CV_OVERRIDE { out << *reinterpret_cast<T const*>(src); } Unexecuted instantiation: cvflann::anyimpl::small_any_policy<char const*>::print(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, void* const*) Unexecuted instantiation: cvflann::anyimpl::small_any_policy<int>::print(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, void* const*) Unexecuted instantiation: cvflann::anyimpl::small_any_policy<float>::print(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, void* const*) Unexecuted instantiation: cvflann::anyimpl::small_any_policy<bool>::print(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, void* const*) |
100 | | }; |
101 | | |
102 | | template<typename T> |
103 | | struct big_any_policy CV_FINAL : typed_base_any_policy<T> |
104 | | { |
105 | | virtual void static_delete(void** x) CV_OVERRIDE |
106 | 0 | { |
107 | 0 | if (* x) delete (* reinterpret_cast<T**>(x)); |
108 | 0 | *x = NULL; |
109 | 0 | } Unexecuted instantiation: cvflann::anyimpl::big_any_policy<cvflann::anyimpl::empty_any>::static_delete(void**) Unexecuted instantiation: cvflann::anyimpl::big_any_policy<cvflann::flann_algorithm_t>::static_delete(void**) Unexecuted instantiation: cvflann::anyimpl::big_any_policy<cvflann::flann_centers_init_t>::static_delete(void**) Unexecuted instantiation: cvflann::anyimpl::big_any_policy<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::static_delete(void**) |
110 | | virtual void copy_from_value(void const* src, void** dest) CV_OVERRIDE |
111 | 0 | { |
112 | 0 | *dest = new T(*reinterpret_cast<T const*>(src)); |
113 | 0 | } Unexecuted instantiation: cvflann::anyimpl::big_any_policy<cvflann::anyimpl::empty_any>::copy_from_value(void const*, void**) Unexecuted instantiation: cvflann::anyimpl::big_any_policy<cvflann::flann_algorithm_t>::copy_from_value(void const*, void**) Unexecuted instantiation: cvflann::anyimpl::big_any_policy<cvflann::flann_centers_init_t>::copy_from_value(void const*, void**) Unexecuted instantiation: cvflann::anyimpl::big_any_policy<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::copy_from_value(void const*, void**) |
114 | | virtual void clone(void* const* src, void** dest) CV_OVERRIDE |
115 | 0 | { |
116 | 0 | *dest = new T(**reinterpret_cast<T* const*>(src)); |
117 | 0 | } Unexecuted instantiation: cvflann::anyimpl::big_any_policy<cvflann::anyimpl::empty_any>::clone(void* const*, void**) Unexecuted instantiation: cvflann::anyimpl::big_any_policy<cvflann::flann_algorithm_t>::clone(void* const*, void**) Unexecuted instantiation: cvflann::anyimpl::big_any_policy<cvflann::flann_centers_init_t>::clone(void* const*, void**) Unexecuted instantiation: cvflann::anyimpl::big_any_policy<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::clone(void* const*, void**) |
118 | | virtual void move(void* const* src, void** dest) CV_OVERRIDE |
119 | 0 | { |
120 | 0 | (*reinterpret_cast<T**>(dest))->~T(); |
121 | 0 | **reinterpret_cast<T**>(dest) = **reinterpret_cast<T* const*>(src); |
122 | 0 | } Unexecuted instantiation: cvflann::anyimpl::big_any_policy<cvflann::anyimpl::empty_any>::move(void* const*, void**) Unexecuted instantiation: cvflann::anyimpl::big_any_policy<cvflann::flann_algorithm_t>::move(void* const*, void**) Unexecuted instantiation: cvflann::anyimpl::big_any_policy<cvflann::flann_centers_init_t>::move(void* const*, void**) Unexecuted instantiation: cvflann::anyimpl::big_any_policy<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::move(void* const*, void**) |
123 | 0 | virtual void* get_value(void** src) CV_OVERRIDE { return *src; } Unexecuted instantiation: cvflann::anyimpl::big_any_policy<cvflann::anyimpl::empty_any>::get_value(void**) Unexecuted instantiation: cvflann::anyimpl::big_any_policy<cvflann::flann_algorithm_t>::get_value(void**) Unexecuted instantiation: cvflann::anyimpl::big_any_policy<cvflann::flann_centers_init_t>::get_value(void**) Unexecuted instantiation: cvflann::anyimpl::big_any_policy<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::get_value(void**) |
124 | 0 | virtual const void* get_value(void* const * src) CV_OVERRIDE { return *src; } Unexecuted instantiation: cvflann::anyimpl::big_any_policy<cvflann::anyimpl::empty_any>::get_value(void* const*) Unexecuted instantiation: cvflann::anyimpl::big_any_policy<cvflann::flann_algorithm_t>::get_value(void* const*) Unexecuted instantiation: cvflann::anyimpl::big_any_policy<cvflann::flann_centers_init_t>::get_value(void* const*) Unexecuted instantiation: cvflann::anyimpl::big_any_policy<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::get_value(void* const*) |
125 | 0 | virtual void print(std::ostream& out, void* const* src) CV_OVERRIDE { out << *reinterpret_cast<T const*>(*src); } |
126 | | }; |
127 | | |
128 | | template<> inline void big_any_policy<flann_centers_init_t>::print(std::ostream& out, void* const* src) |
129 | 0 | { |
130 | 0 | out << int(*reinterpret_cast<flann_centers_init_t const*>(*src)); |
131 | 0 | } |
132 | | |
133 | | template<> inline void big_any_policy<flann_algorithm_t>::print(std::ostream& out, void* const* src) |
134 | 0 | { |
135 | 0 | out << int(*reinterpret_cast<flann_algorithm_t const*>(*src)); |
136 | 0 | } |
137 | | |
138 | | template<> inline void big_any_policy<cv::String>::print(std::ostream& out, void* const* src) |
139 | 0 | { |
140 | 0 | out << (*reinterpret_cast<cv::String const*>(*src)).c_str(); |
141 | 0 | } |
142 | | |
143 | | template<typename T> |
144 | | struct choose_policy |
145 | | { |
146 | | typedef big_any_policy<T> type; |
147 | | }; |
148 | | |
149 | | template<typename T> |
150 | | struct choose_policy<T*> |
151 | | { |
152 | | typedef small_any_policy<T*> type; |
153 | | }; |
154 | | |
155 | | struct any; |
156 | | |
157 | | /// Choosing the policy for an any type is illegal, but should never happen. |
158 | | /// This is designed to throw a compiler error. |
159 | | template<> |
160 | | struct choose_policy<any> |
161 | | { |
162 | | typedef void type; |
163 | | }; |
164 | | |
165 | | /// Specializations for small types. |
166 | | #define SMALL_POLICY(TYPE) \ |
167 | | template<> \ |
168 | | struct choose_policy<TYPE> { typedef small_any_policy<TYPE> type; \ |
169 | | } |
170 | | |
171 | | SMALL_POLICY(signed char); |
172 | | SMALL_POLICY(unsigned char); |
173 | | SMALL_POLICY(signed short); |
174 | | SMALL_POLICY(unsigned short); |
175 | | SMALL_POLICY(signed int); |
176 | | SMALL_POLICY(unsigned int); |
177 | | SMALL_POLICY(signed long); |
178 | | SMALL_POLICY(unsigned long); |
179 | | SMALL_POLICY(float); |
180 | | SMALL_POLICY(bool); |
181 | | |
182 | | #undef SMALL_POLICY |
183 | | |
184 | | template <typename T> |
185 | | class SinglePolicy |
186 | | { |
187 | | SinglePolicy(); |
188 | | SinglePolicy(const SinglePolicy& other); |
189 | | SinglePolicy& operator=(const SinglePolicy& other); |
190 | | |
191 | | public: |
192 | | static base_any_policy* get_policy(); |
193 | | }; |
194 | | |
195 | | /// This function will return a different policy for each type. |
196 | | template <typename T> |
197 | | inline base_any_policy* SinglePolicy<T>::get_policy() |
198 | 0 | { |
199 | 0 | static typename choose_policy<T>::type policy; |
200 | 0 | return &policy; |
201 | 0 | } Unexecuted instantiation: cvflann::anyimpl::SinglePolicy<cvflann::anyimpl::empty_any>::get_policy() Unexecuted instantiation: cvflann::anyimpl::SinglePolicy<char const*>::get_policy() Unexecuted instantiation: cvflann::anyimpl::SinglePolicy<int>::get_policy() Unexecuted instantiation: cvflann::anyimpl::SinglePolicy<float>::get_policy() Unexecuted instantiation: cvflann::anyimpl::SinglePolicy<bool>::get_policy() Unexecuted instantiation: cvflann::anyimpl::SinglePolicy<cvflann::flann_algorithm_t>::get_policy() Unexecuted instantiation: cvflann::anyimpl::SinglePolicy<cvflann::flann_centers_init_t>::get_policy() Unexecuted instantiation: cvflann::anyimpl::SinglePolicy<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::get_policy() |
202 | | |
203 | | } // namespace anyimpl |
204 | | |
205 | | struct any |
206 | | { |
207 | | private: |
208 | | // fields |
209 | | anyimpl::base_any_policy* policy; |
210 | | void* object; |
211 | | |
212 | | public: |
213 | | /// Initializing constructor. |
214 | | template <typename T> |
215 | | any(const T& x) |
216 | | : policy(anyimpl::SinglePolicy<anyimpl::empty_any>::get_policy()), object(NULL) |
217 | | { |
218 | | assign(x); |
219 | | } |
220 | | |
221 | | /// Empty constructor. |
222 | | any() |
223 | | : policy(anyimpl::SinglePolicy<anyimpl::empty_any>::get_policy()), object(NULL) |
224 | 0 | { } |
225 | | |
226 | | /// Special initializing constructor for string literals. |
227 | | any(const char* x) |
228 | | : policy(anyimpl::SinglePolicy<anyimpl::empty_any>::get_policy()), object(NULL) |
229 | 0 | { |
230 | 0 | assign(x); |
231 | 0 | } |
232 | | |
233 | | /// Copy constructor. |
234 | | any(const any& x) |
235 | | : policy(anyimpl::SinglePolicy<anyimpl::empty_any>::get_policy()), object(NULL) |
236 | 0 | { |
237 | 0 | assign(x); |
238 | 0 | } |
239 | | |
240 | | /// Destructor. |
241 | | ~any() |
242 | 0 | { |
243 | 0 | policy->static_delete(&object); |
244 | 0 | } |
245 | | |
246 | | /// Assignment function from another any. |
247 | | any& assign(const any& x) |
248 | 0 | { |
249 | 0 | reset(); |
250 | 0 | policy = x.policy; |
251 | 0 | policy->clone(&x.object, &object); |
252 | 0 | return *this; |
253 | 0 | } |
254 | | |
255 | | /// Assignment function. |
256 | | template <typename T> |
257 | | any& assign(const T& x) |
258 | 0 | { |
259 | 0 | reset(); |
260 | 0 | policy = anyimpl::SinglePolicy<T>::get_policy(); |
261 | 0 | policy->copy_from_value(&x, &object); |
262 | 0 | return *this; |
263 | 0 | } Unexecuted instantiation: cvflann::any& cvflann::any::assign<char const*>(char const* const&) Unexecuted instantiation: cvflann::any& cvflann::any::assign<int>(int const&) Unexecuted instantiation: cvflann::any& cvflann::any::assign<float>(float const&) Unexecuted instantiation: cvflann::any& cvflann::any::assign<bool>(bool const&) Unexecuted instantiation: cvflann::any& cvflann::any::assign<cvflann::flann_algorithm_t>(cvflann::flann_algorithm_t const&) Unexecuted instantiation: cvflann::any& cvflann::any::assign<cvflann::flann_centers_init_t>(cvflann::flann_centers_init_t const&) Unexecuted instantiation: cvflann::any& cvflann::any::assign<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) |
264 | | |
265 | | /// Assignment operator. |
266 | | template<typename T> |
267 | | any& operator=(const T& x) |
268 | 0 | { |
269 | 0 | return assign(x); |
270 | 0 | } Unexecuted instantiation: cvflann::any& cvflann::any::operator=<int>(int const&) Unexecuted instantiation: cvflann::any& cvflann::any::operator=<float>(float const&) Unexecuted instantiation: cvflann::any& cvflann::any::operator=<bool>(bool const&) Unexecuted instantiation: cvflann::any& cvflann::any::operator=<cvflann::flann_algorithm_t>(cvflann::flann_algorithm_t const&) Unexecuted instantiation: cvflann::any& cvflann::any::operator=<cvflann::flann_centers_init_t>(cvflann::flann_centers_init_t const&) Unexecuted instantiation: cvflann::any& cvflann::any::operator=<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) |
271 | | |
272 | | /// Assignment operator. Template-based version above doesn't work as expected. We need regular assignment operator here. |
273 | | any& operator=(const any& x) |
274 | 0 | { |
275 | 0 | return assign(x); |
276 | 0 | } |
277 | | |
278 | | /// Assignment operator, specialed for literal strings. |
279 | | /// They have types like const char [6] which don't work as expected. |
280 | | any& operator=(const char* x) |
281 | 0 | { |
282 | 0 | return assign(x); |
283 | 0 | } |
284 | | |
285 | | /// Utility functions |
286 | | any& swap(any& x) |
287 | 0 | { |
288 | 0 | std::swap(policy, x.policy); |
289 | 0 | std::swap(object, x.object); |
290 | 0 | return *this; |
291 | 0 | } |
292 | | |
293 | | /// Cast operator. You can only cast to the original type. |
294 | | template<typename T> |
295 | | T& cast() |
296 | | { |
297 | | CV_THROW_IF_TYPE_MISMATCH(policy->type(), typeid(T)); |
298 | | T* r = reinterpret_cast<T*>(policy->get_value(&object)); |
299 | | return *r; |
300 | | } |
301 | | |
302 | | /// Cast operator. You can only cast to the original type. |
303 | | template<typename T> |
304 | | const T& cast() const |
305 | | { |
306 | | CV_THROW_IF_TYPE_MISMATCH(policy->type(), typeid(T)); |
307 | | const T* r = reinterpret_cast<const T*>(policy->get_value(&object)); |
308 | | return *r; |
309 | | } |
310 | | |
311 | | /// Returns true if the any contains no value. |
312 | | bool empty() const |
313 | 0 | { |
314 | 0 | return policy->type() == typeid(anyimpl::empty_any); |
315 | 0 | } |
316 | | |
317 | | /// Frees any allocated memory, and sets the value to NULL. |
318 | | void reset() |
319 | 0 | { |
320 | 0 | policy->static_delete(&object); |
321 | 0 | policy = anyimpl::SinglePolicy<anyimpl::empty_any>::get_policy(); |
322 | 0 | } |
323 | | |
324 | | /// Returns true if the two types are the same. |
325 | | bool compatible(const any& x) const |
326 | 0 | { |
327 | 0 | return policy->type() == x.policy->type(); |
328 | 0 | } |
329 | | |
330 | | /// Returns if the type is compatible with the policy |
331 | | template<typename T> |
332 | | bool has_type() |
333 | | { |
334 | | return policy->type() == typeid(T); |
335 | | } |
336 | | |
337 | | const std::type_info& type() const |
338 | 0 | { |
339 | 0 | return policy->type(); |
340 | 0 | } |
341 | | |
342 | | friend std::ostream& operator <<(std::ostream& out, const any& any_val); |
343 | | }; |
344 | | |
345 | | inline std::ostream& operator <<(std::ostream& out, const any& any_val) |
346 | 0 | { |
347 | 0 | any_val.policy->print(out,&any_val.object); |
348 | 0 | return out; |
349 | 0 | } |
350 | | |
351 | | } |
352 | | |
353 | | //! @endcond |
354 | | |
355 | | #endif // OPENCV_FLANN_ANY_H_ |