STD ::切换到Boost 1.64时获得冲突

std::get conflict when switching to Boost 1.64

本文关键字:64时 冲突 Boost STD      更新时间:2023-10-16

我使用的是gcc 6.2(with -std = c 14)。我有一个大型项目,该项目与Boost 1.62建立,没有任何问题。当我切换到Boost 1.64时,我会收到此错误:

.../include/boost/property_map/property_map.hpp:133:11: error: ‘template<long unsigned int Idx, class T, long unsigned int N> con 
    st T& std::get(const boost::array<T, N>&)’ conflicts with a previous declaration 
      using ::get; 
              ^~~ 
...include//boost/array.hpp:429:13: note: previous declaration ‘template<long unsigned int Idx, class T, long unsigned int N> con 
    st T& boost::get(const boost::array<T, N>&)’ 
       const T &get(const boost::array<T,N> &arr) BOOST_NOEXCEPT { 
                ^~~ 

不幸的是,我无法用一个简单的示例来重现问题(不确定问题可能是什么,我制作了一个空的main(),其中包括 property_map.hpparray.hpp,并且可以很好地构建),所以我正在寻找一个朝正确的方向轻推:)。

确保寻找导入单个功能的语句:

using std::get;

而不仅仅是导入包含get()的全名空间:

using namespace std;

这是因为boost在array.hpp vesion 1.64中介绍了该模板函数,array.hpp vesion 1.62
not.hpp vesion 1.64(这就是为什么您之前没有出现此编译器错误)

template<typename T, std::size_t N, std::size_t Idx> 
    T boost::get(const array<T, N>&);

无论如何,问题是因为您在代码中的某个地方将命名空间(stdboost)混合在一起。请参阅std :: get

在标题中摆脱using namespace std;using namespace boost;