我想要一個static constexpr數組類元素的模板類內類似於以下代碼的靜態constexpr模板陣列構件這個例子,但它已經顯示了這個問題。如果我編譯這個機智gcc我得到一個遞歸依賴性的錯誤: test.cc: In instantiation of ‘constexpr Element Template<true>::element [2]’:
test.cc:11:27: recurs
#include <iostream>
using namespace std;
template<const int arr[]>
struct S {
static constexpr int value = arr[0];
};
constexpr int arr[] = { 5 };
int main() {
cout << S<arr>::valu