mpl and fusion containers: numbered vs variadic

Hello, Is it true that as a general rule, using the numbered version instead of the variadic version yields faster compile times? Or is it just about compilers supporting variadic templates? MM

"MM" <finjulhich@gmail.com> writes:
Is it true that as a general rule, using the numbered version instead of the variadic version yields faster compile times? Or is it just about compilers supporting variadic templates?
IIRC Fusion currently implements the variadic vector in terms of the fixed numeric ones. (And all other container on top of the vector.) This is, the use of a numeric vector should be slightly faster than the use of the variadic one. If C++11's variadic templates are used, it will be easiest to implement the numbered ones using an unnumbered, variadic implementation in combination with template aliases, though. Christopher

On 05/27/12 14:49, Christopher Schmidt wrote:
"MM"<finjulhich@gmail.com> writes:
Is it true that as a general rule, using the numbered version instead of the variadic version yields faster compile times? Or is it just about compilers supporting variadic templates?
IIRC Fusion currently implements the variadic vector in terms of the fixed numeric ones. (And all other container on top of the vector.) This is, the use of a numeric vector should be slightly faster than the use of the variadic one.
If C++11's variadic templates are used, it will be easiest to implement the numbered ones using an unnumbered, variadic implementation in combination with template aliases, though.
Christopher Hi Christopher,
Could you please provide an example implementation of this C++11 implementation? I've no idea how template aliases could be used :( TIA. -regards, Larry

Larry Evans <cppljevans@suddenlink.net> writes:
Could you please provide an example implementation of this C++11 implementation? I've no idea how template aliases could be used :(
Actually it is the other way round, the language feature is called alias template. (N3337, 14.5.7) template <typename...> class container; template <typename A> using container1 = container<A>; This is pretty cool because AFAIK from a typization point of view there is no difference between container<A> and container1<A>. This is incredibly useful when one uses specialisations instead of explicit template metaprogramming to optimise in regard to compile-time as it is being done, for example, in Boost.Spirit. Other than that, the numeric aliases can easily be generated using the preprocessor and there is no real overhead imposed to the compilation session. Even better, one can use template aliases to define the front-end Fusion container types in terms of a single, shared backend implementation. This is useful because that way there are way less heavy template instantiations as the containers now do not built up-on each other any more. Christopher
participants (3)
-
Christopher Schmidt
-
Larry Evans
-
MM