[cfe-dev] Additional instantiations of anonymous enum inside a template
Pavel Morozkin
pavel.morozkin at gmail.com
Sun Oct 12 03:29:32 PDT 2014
Hello cfe-dev group,
Consider this template metaprogram:
template <unsigned N> struct fib { enum { value = fib<N-1>::value +
fib<N-2>::value}; };
template <> struct fib<1> { enum { value = 1 }; };
template <> struct fib<0> { enum { value = 0 }; };
During compilation of 'fib<2>::value' (after finally getting memoized
result of instantiation of struct fib<0>) Clang «instantiates the anonymous
enum inside fib<0> and fib<1>» 129 times in sum. In case, when we use
'constexpr static auto' instead of 'enum', no additional instantiations
occurs. Why Clang performs additional instantiations in the first case?
Thank you,
Pavel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20141012/8e0baf42/attachment.html>
More information about the cfe-dev
mailing list