diff --git a/modules/flann/include/opencv2/flann/any.h b/modules/flann/include/opencv2/flann/any.h index 070d5a421f..4a58cf2dc4 100644 --- a/modules/flann/include/opencv2/flann/any.h +++ b/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 const 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 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(src); } + virtual const void* get_value(void* const * src) { return reinterpret_cast(src); } virtual void print(std::ostream& out, void* const* src) { out << *reinterpret_cast(src); } }; @@ -93,6 +95,7 @@ struct big_any_policy : typed_base_any_policy **reinterpret_cast(dest) = **reinterpret_cast(src); } virtual void* get_value(void** src) { return *src; } + virtual const void* get_value(void* const * src) { return *src; } virtual void print(std::ostream& out, void* const* src) { out << *reinterpret_cast(*src); } }; @@ -257,7 +260,7 @@ public: const T& cast() const { if (policy->type() != typeid(T)) throw anyimpl::bad_any_cast(); - T* r = reinterpret_cast(policy->get_value(const_cast(&object))); + const T* r = reinterpret_cast(policy->get_value(&object)); return *r; }