Cherry-picked mariusmuja/flann@b615f2694723fe402b8bbe50d77e622beff7f171.

Original author: Alex Wilson.
pull/1550/head
Roman Donchenko 11 years ago
parent 78c4ffec99
commit 4c19e0273a
  1. 6
      modules/flann/include/opencv2/flann/any.h

@ -44,6 +44,7 @@ struct base_any_policy
virtual void clone(void* const* src, void** dest) = 0;
virtual void move(void* const* src, void** dest) = 0;
virtual void* get_value(void** src) = 0;
virtual void* get_value(void* const * src) = 0;
virtual ::size_t get_size() = 0;
virtual const std::type_info& type() = 0;
virtual void print(std::ostream& out, void* const* src) = 0;
@ -69,6 +70,7 @@ struct small_any_policy : typed_base_any_policy<T>
virtual void clone(void* const* src, void** dest) { *dest = *src; }
virtual void move(void* const* src, void** dest) { *dest = *src; }
virtual void* get_value(void** src) { return reinterpret_cast<void*>(src); }
virtual void* get_value(void* const * src) { return const_cast<void *>( reinterpret_cast<const void*>(src) ); }
virtual void print(std::ostream& out, void* const* src) { out << *reinterpret_cast<T const*>(src); }
};
@ -93,6 +95,7 @@ struct big_any_policy : typed_base_any_policy<T>
**reinterpret_cast<T**>(dest) = **reinterpret_cast<T* const*>(src);
}
virtual void* get_value(void** src) { return *src; }
virtual void* get_value(void* const * src) { return const_cast<void*>(*src); }
virtual void print(std::ostream& out, void* const* src) { out << *reinterpret_cast<T const*>(*src); }
};
@ -257,8 +260,7 @@ public:
const T& cast() const
{
if (policy->type() != typeid(T)) throw anyimpl::bad_any_cast();
void* obj = const_cast<void*>(object);
T* r = reinterpret_cast<T*>(policy->get_value(&obj));
T* r = reinterpret_cast<T*>(policy->get_value(&object));
return *r;
}

Loading…
Cancel
Save