woops I guess I missed that. They are type parameters of metatype class. The reason I am asking is I am writing a pass through function to the STL container which is embedded in the class so I am curious what type definition i should give the function formal. I speculate from this I will just define it as:
Silenus, it depends on the algorithm you're using. for_each just calls the function once for each member, and the return value is ignored. Something like find_if is also a unary function, but must return any value convertable to bool.
The algorithms are all implemented as templates so they're not at all strict on types. Anything that is implicitly convertable between what the algorithm is using and what your function uses is fine. You can also write your predicates as templates if you feel you might need to reuse the same logic on a few different types.
Thanks. I guess I will have to check an STL guide and see how the conversions are taking place. The problem sometimes with template arguments is it's difficult to tell (since they are too generic) what exactly is expected in terms of "type signature". There is a fair deal I dont understand here.
Thanks.
01 Sep, 2009, David Haley wrote in the 8th comment:
Votes: 0
Isn't the whole point of template arguments to be generic? I guess I'm not sure I understand your question?
The good thing is that often the STL source is available for you to read. The bad thing is that it's written using a very obscure style of coding that I find makes it very hard to read until you get used to it.
Actually it's a comment w.r.t. the fact that additional constraints on a generic argument tend to exist but cannot be determined under the template is instantiated. Yeah I wonder if my skill level is at the point I can read the STL source code yet. I guess there is one way to find out :P.
01 Sep, 2009, David Haley wrote in the 10th comment:
Votes: 0
It's not really a question of skill level to be honest. They just use a rather peculiar way of writing things that is extremely terse and requires unpacking. They seem to think that long variable names are evil, for example. :wink: Also, since they code for very high efficiency, sometimes things happen and it's not obvious why, but it makes things faster.