2017-10-10 42 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; 
};