Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 28 Jun 2011
Offline Last Active Sep 21 2015 09:40 AM

#5251123 C++11 lambda, modifying copied value

Posted by vdaras on 08 September 2015 - 03:02 AM


Also, it's advisable not to store lambdas in std::function objects. 


As you saying, don't store lambdas in std::function unless you need to (i.e. passing a lambda into a function that takes std::function as a parameter), or are you saying never use std::function to store a lambda?


I store lambdas in std::function all the time. Ofcourse if the lambda doesn't need to be stored for later calling, I just use auto, but since I still use std::function alot, I'd like to know if there's a problem with that that I'm not aware of.


Are you saying that std::function's member vars takes a few extra bytes to hold the object, which requires a separate allocation (definitely worth pointing out), or are you warning about something more dangerous? mellow.png



You are right I didn't put that correctly. It's totally fine storing them in std::function objects if there is no alternative to the task at hand.


The problem with std::function is that its the same size for every kind of function it could store, so it does extra allocations if its memory is not enough to store bookkeeping information about the lambda.


Imagine having a game with tons of those small allocations each frame because you just define and store some lambdas. It could hinder performance.

#5251068 C++11 lambda, modifying copied value

Posted by vdaras on 07 September 2015 - 04:20 PM

Also, it's advisable not to store lambdas in std::function objects. It might cost extra memory allocation.


The type of each different lambda is known only to the compiler, so use auto instead.

#5048874 Game programming architecture

Posted by vdaras on 01 April 2013 - 09:03 AM

A good reading people often recommend is Game Coding Complete by Mike McShaffry. I've read it myself too and I suggest that it is a great one! It covers a lot of introductory topics on game development and game code architecture as well as some advanced ones. It has some great advice on how you can decouple your game's subsystems.


Another good one is Game Engine Archtecture by Jason Gregory. It covers a lot of ground on game engines but in a more abstract manner than the previous one.

#5007351 Ooops... XNA is dead?!.

Posted by vdaras on 05 December 2012 - 04:43 AM

With their native code push I don't think its entirely infeasible to suggest that the "XNA Replacement" on the next gen console could well support native code with a few restrictions, maybe still requiring the indie license and using the same distribution methods, if this is the case it would also be theoretically possible for a monogame port I guess. I wonder if monogame on WP8 is possible

Monogame is definitely possible on WP8. As is Microsoft's XNA.

The problem with XNA is that, from what we know so far, it won't be supported anymore..so no new WP8 features for XNA apps.

#5006609 Problem with destructors in C++

Posted by vdaras on 03 December 2012 - 08:46 AM

My bet is that sooner123 doesn't understand the pointer concept very well.


[source lang="cpp"]Node* sentinel = new Node;[/source]

This line of code creates a new object of the Node class on the free store and makes the sentinel pointer reference that object.

So in order to make your pointer reference the pre-existing Node object, which you wanted to do in the first place, you just need this

[source lang="cpp"]Node* sentinel = list;[/source]

Sorry for stating the obvious to the vast majority of you, but from what I got from sooner123's responses, the op probably didn't understand why allocating the
new node was unnecessary.

#4853209 [java] NEEDED: A kick-ass *junior* Java developer who wants to live in Barcel...

Posted by vdaras on 24 August 2011 - 08:07 AM

You ask for someone to leave his/her country, move to a foreign country where English is needed but English is not the native speaking language. Then you need him/her to move to an expensive city as Barcelona, where paying the rent would effectively diminish the 800E salary to 1/3 and probably more. Otherwise, if he/she chooses to leave in a suburban area of Barcelona, much more money will be paid on transport every month.

Sorry but you need much better arguments than 'I have super project idea' that no one knows anything about and ' I'm a badass programmer' in order to convice someone to do that.