Originally Posted By: the_clown
Ah, so the problem here is the fact that it's a templated method?
Interesting pitfall.

Kind of, but it wouldn't work without templates either. If you declare it static, you would get an instantiation per compilation unit that makes use of it. Without static, your linker would complain about duplicated symbols. Because it's a template, the linker will collapse the multiple instantiations down to one.

Originally Posted By: the_clown
Hmm I could imagine it's the fact you're doing the whole thing with a single function call using C++'s Lambda feature? At least I think that's quite a nice thing.

Getting close. The real nice thing is that it doesn't pollute the outer scope with "rect" and makes the whole thing look nicer (imho anyways). Here is the context: https://github.com/uberpixel/Downpour/bl...w.cpp#L169-L175

It really is just a much nicer way of writing this:
Code:
RN::Rect rect = _titleLabel->GetFrame();

rect.x = 5.0f;
rect.y = 5.0f;

_titleLabel->SetFrame(rect);

// Why does rect have to still be visible here?!



I sue this kind of sparingly and only when it makes sense to limit the scope and visibility of variables.

Edit: Are we allowed multiple posts? I know one can only have _one_ favourite, but what about other really neat snippets?

Last edited by WretchedSid; 08/12/14 20:52.

Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com