// since we can dedfine a static array like this
int a[5] = {0};
// decltype(a[5]) is `int [5]`
// Then how about this way?
constexpr int sum(int a, int b) { return a + b; }
int a, b;
std::cin >> a >> b;
int arr[sum(a, b)] = {0};
it can be compiled successfully, but is arr a static array?
when I tried to print arr type with typeid().name() or boost::typeindex::type_id_with_cvr, I got below error:
error: cannot create type information for type 'int [(<anonymous> + 1)]' because it involves types of variable size
std::cout << typeid(decltype(arr)).name() << std::endl;
suminvocation requires it to be invoked at compile time, for functionsumto be evaluated to compile time both arguments are required to be known at compile time.