July 28th, 2009, 01:08 PM
STL Style function parameters?
I really like how the STL allows you to toss in a struct with a certain function present and it will use it like a function pointer (i.e. the various operators for sorting routines etc).
I'd like to use something similar myself, but the code is rather convoluted and I wasn't able to figure out how they are doing it so that I don't actually have to pass the type as a template parameter.
Does anyone know the trick they use that allows it? Is it really just looking for a function pointer or is there some sort of magic template trick that is letting that happen. If I try to use templates, I have to declare the correct type ahead of time, which doesn't work for what I want to do with it (I want that function object to be used only for that one function, and it needs to maintain some state).
Tags for this Thread
Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.