当前位置: 代码迷 >> 综合 >> 【错误记录/boost】error: static assertion failed: boost::variant does not contain specified type U, call t
  详细解决方案

【错误记录/boost】error: static assertion failed: boost::variant does not contain specified type U, call t

热度:54   发布时间:2024-01-27 02:53:23.0

错误详情

In file included from /usr/local/include/boost/iterator/iterator_categories.hpp:22,from /usr/local/include/boost/iterator/iterator_facade.hpp:14,from /usr/local/include/boost/filesystem/path.hpp:28,from /usr/local/include/boost/filesystem.hpp:16,from /home/pi/model/include/model_output_labels_loader.hpp:7,from /home/pi/model/mob.cpp:5:
/usr/local/include/boost/variant/get.hpp: In instantiation of ‘typename boost::add_reference<T>::type boost::strict_get(boost::variant<T0, TN ...>&) [with U = std::vector<unsigned char>; T0 = std::vector<float>; TN = {}; typename boost::add_reference<T>::type = std::vector<unsigned char>&]’:
/usr/local/include/boost/variant/get.hpp:292:25:   required from ‘typename boost::add_reference<T>::type boost::get(boost::variant<T0, TN ...>&) [with U = std::vector<unsigned char>; T0 = std::vector<float>; TN = {}; typename boost::add_reference<T>::type = std::vector<unsigned char>&]’
/home/pi/model/mob.cpp:114:91:   required from here
/usr/local/include/boost/variant/get.hpp:220:5: error: static assertion failed: boost::variant does not contain specified type U, call to boost::get<U>(boost::variant<T...>&) will always throw boost::bad_get exception220 |     BOOST_STATIC_ASSERT_MSG(|     ^~~~~~~~~~~~~~~~~~~~~~~

解决方案

  • here
  • 即添加定义
    #define BOOST_VARIANT_USE_RELAXED_GET_BY_DEFAULT
    
  相关解决方案