Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C++ Template Question

Name: Anonymous 2012-10-07 21:47


template <size_t N>
void print_members(int (&arr)[N]) { ... }


so is C++ going to create a new function for every different sized array I use

Name: Anonymous 2012-10-08 13:34

>>6
I think it's more interesting to look at the generated assembly code. The problem being that loading an immediate takes 1 cycle on most (if not all) architectures and loading from memory can take 300 cycles, making the condensed code extremely slow should it decide to use RAM to store this data. It also means that cache will have to be updated, pushing data that actually needs to be in RAM out.

That said, I don't think that optimization would come into play all that often.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List