diff --git a/src/bindings/cxx/eina_cxx/eina_variant.hh b/src/bindings/cxx/eina_cxx/eina_variant.hh index df24aea433..358688a0bb 100644 --- a/src/bindings/cxx/eina_cxx/eina_variant.hh +++ b/src/bindings/cxx/eina_cxx/eina_variant.hh @@ -142,7 +142,7 @@ struct destroy_visitor { typedef void result_type; template - void operator()(T&& other) const + void operator()(T&& other) const noexcept { typedef typename std::remove_cv::type>::type type; other.~type(); @@ -229,13 +229,16 @@ struct variant void destroy() { - destroy_unsafe(); - type = -1; + if(type != -1) + { + destroy_unsafe(); + type = -1; + } } void destroy_unsafe() { - visit(destroy_visitor()); + visit_unsafe(destroy_visitor()); } bool empty() const @@ -264,6 +267,18 @@ struct variant else return call_visitor<0u, sizeof...(Args), std::tuple>::call(type, static_cast(&buffer), f); } + + template + typename F::result_type visit_unsafe(F f) const + { + return call_visitor<0u, sizeof...(Args), std::tuple>::call(type, static_cast(&buffer), f); + } + + template + typename F::result_type visit_unsafe(F f) + { + return call_visitor<0u, sizeof...(Args), std::tuple>::call(type, static_cast(&buffer), f); + } private: template