On Wed, Jun 20, 2012 at 2:28 AM, Stefan Stavrev <[email protected]> wrote:
> I am trying to put type specialization in one general function. I am not
> sure how to implement variable size argument list, should I use features
> from the new c++ standard, should I use va_list, or else ? Here is some
> pseudo code for specializing 5 types:
>
> http://ideone.com/pgLwk

Interesting approach, but better be careful: You've just forced the
compiler to generate something like 5 * 11^5 = 805255 specializations!
Even if it didn't cause the compiler to fall over, actually calling this
function with concrete types would result in a horrifying amount of code
bloat ;-)

It's probably unrealistic to want full specialization for more than two
or - at the absolute most - three concrete types, because that results
in 11^2 = 121 or 11^3 = 1331 generated functions respectively.

I'm afraid there's really no way around this combinatoric nightmare in
C++, other than dynamic dispatch.  (The only way to have fully
specialized efficiency and avoid code bloat is to use dynamic code
generation, aka a JIT.)

~Chris
_______________________________________________
Oiio-dev mailing list
[email protected]
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org

Reply via email to