2017-10-10 74 views
0

我遇到了gcc 7.2的一些问题。我有这种类型的特质GCC 7没有选择正确的类型特征专业

template<typename T> 
struct audio_frame_channels {} 

template<int N> 
struct audio_frame_channels<std::array<float, N>> { 
    static constexpr auto value = N; 
}; 

然后我用这样的:

template<typename T> 
    auto redirect(T& buf) -> 
    ProcessData<audio_frame_channels<std::remove_reference_t< 
            decltype(buf[0])>>::value>; 

铛6有这个没有问题,但GCC 7.2抱怨‘value’ is not a member of ‘top1::audio::audio_frame_channels<std::array<float, 1> >’ 是我所得到的东西错了,或者是这是你在实验编译器上得到的结果吗?

编辑:强制性godbolting:

https://godbolt.org/g/Y1EFYC

回答

1

std::array第二个模板参数是一个std::size_t,不int。你需要像这样改变它:

template<std::size_t N> //instead of int N 
struct audio_frame_channels<std::array<float, N>> { 
    static constexpr auto value = N; 
};