openCV library for Renesas RZ/A

Dependents:   RZ_A2M_Mbed_samples

Committer:
RyoheiHagimoto
Date:
Fri Jan 29 04:53:38 2021 +0000
Revision:
0:0e0631af0305
copied from https://github.com/d-kato/opencv-lib.

Who changed what in which revision?

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