In a certain compilation I need to play around with the option -ftemplate-depth=N
that specifies the maximum template recursion.
Is it possible to access the value of the maximum template depth from the program?
I am interested in gcc
or clang
.
$ c++ -ftemplate-depth=128 main.cpp
#include<iostream>
int main(){
std::cout << MAX_TEMPLATE_RECURSION << std::endl; // hypothetical name
}
std::array
doesn't have astatic size()
function. https://mcmap.net/q/398471/-why-isn-39-t-std-array-size-static. Currently I have to hard code the max recursion limit. – Ancylostomiasistemplate <typename> struct array_size; template <typename T, size_t N> struct array_size<std::array<T, N>> { static const size_t result = N; };
? – Wilscamstd::array
, unless perhaps you want to allow an inaccessible/ambiguous base. See coliru.stacked-crooked.com/a/c3c9e3ee78d9509d – Anking