#pragma once #include "friendly_fusion.hpp" #include "index_list.hpp" #include #include #include template QVariant to_qvariant(boost::any const& x) { return QVariant::fromValue(boost::any_cast(x)); } template QVariant to_qvariant(boost::any const& x) { typedef friendly_fusion::result_of::begin begin; typedef friendly_fusion::result_of::advance_c adv_it; typedef friendly_fusion::result_of::deref deref; typedef typename std::decay::type value_type; return to_qvariant(x); } #if defined( __GNUC__ ) && !defined( __clang__ ) template std::function to_qvariant_lambda() { return [](boost::any const& any) { return to_qvariant(any); }; } #endif //defined( __GNUC__ ) && !defined( __clang__ ) template QVariant to_qvariant(boost::any const& any, int index, indices) { typedef std::function element_type; static element_type table[] = { #if defined( __GNUC__ ) && !defined( __clang__ ) //Workaround for gcc bug: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47226 to_qvariant_lambda() ... #else [](boost::any const& any){return to_qvariant(any);} ... #endif //defined( __GNUC__ ) && !defined( __clang__ ) }; return table[index](any); } template QVariant to_qvariant(boost::any const& x, int index) { typedef typename friendly_fusion::result_of::size::type seq_size; typedef typename build_indices::type indices_type; return to_qvariant(x, index, indices_type{}); } template boost::any to_boost_any(QVariant const& x) { return boost::any(x.value()); } template boost::any to_boost_any(QVariant const& x) { typedef friendly_fusion::result_of::begin begin; typedef friendly_fusion::result_of::advance_c adv_it; typedef friendly_fusion::result_of::deref deref; typedef typename std::decay::type value_type; return to_boost_any(x); } #if defined( __GNUC__ ) && !defined( __clang__ ) template std::function to_boost_any_lambda() { return [](QVariant const& value) { return to_boost_any(value); }; } #endif //defined( __GNUC__ ) && !defined( __clang__ ) template boost::any to_boost_any(QVariant const& value, int index, indices) { typedef std::function element_type; static element_type table[] = { #if defined( __GNUC__ ) && !defined( __clang__ ) //Workaround for gcc bug: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47226 to_boost_any_lambda() ... #else [](QVariant const& value){return to_boost_any(value);} ... #endif //defined( __GNUC__ ) && !defined( __clang__ ) }; return table[index](value); } template boost::any to_boost_any(QVariant const& x, int index) { typedef typename friendly_fusion::result_of::size::type seq_size; typedef typename build_indices::type indices_type; return to_boost_any(x, index, indices_type{}); }