C ++ 0x TMP compilation speed

This question focuses on metaprogramming patterns. I found two articles ( one and two , but two do not show convincing evidence, but I trust the statements) that provide evidence that prototype C ++ 0x compilers change exponential compilation time to linear compilation time.

I have a vague understanding that auto, decltype and variadic templates will have something to contribute to. I would like this to explain the changes in the languages ​​and technologies of the compiler that allow this, especially explaining how and why.

In terms of my skill level, I used the spirit of supporting the TMP library in anger and some MPL game programs.

+3
source share
1 answer

It is clear that the former is slower to process for the compiler than the latter, and there is, as you say, evidence for this .

/* first */
template<typename A>
void f(A const&);
template<typename A>
void f(A&);

template<typename A1, typename A2>
void f(A1 const&, A2&);
template<typename A1, typename A2>
void f(A1&, A2 const&);
template<typename A1, typename A2>
void f(A1 const&, A2 const&);
template<typename A1, typename A2>
void f(A1&, A2&);

// ...

/* second */
template<typename ...T>
void f(T &&...);

I don't know a workaround for something completely common autoin C ++. Modeling autorequires hundreds, if not thousands of lines of code (see Boost.typeof), and then it is not yet common. The same for decltype.

+3
source

Source: https://habr.com/ru/post/1795046/


All Articles