Sign in to follow this  
  • entries
  • comments
  • views

C++0x as per VS2010

Sign in to follow this  


So, I've come to a conclusion about C++0x; I do love the lambda stuff [grin]

float multiplier[] = { -1, 1};
int i = 0;
int j = 0;
std::for_each(dataPoints.begin(), dataPoints.end(), [&](PointAffinity dataPoint)
pData.m_driveValue = bands[dataPoint.side][j] * multiplier[sourceSelect] * 7.0f;
pData.position = dataPoint.position;
if(i % 2 == 0)

Something about being able to write that inline is rather nice [smile]

Then there is always this little bit of fun;

int counter = 0;
float multiplier = 1.0f;
std::for_each(dataPoints.begin(), dataPoints.end(), [&](PointAffinity &point)
point.incAmount *= multiplier;
if(point.side == 0)
if(counter % 2)
multiplier += 0.2f;

And having 'bind' as part of the std namespace is nice as well;

struct ID3D11CommandList;
struct ID3D11DeviceContext;

typedef std::function<void (ID3D11DeviceContext*)> deferredFunction_t;

struct RendererCommand
RendererCommand() : cmdID(EDrawingCommand_NOP), cmd(NULL), time(0) {};
RendererCommand(DrawingCommandType cmdID, ID3D11CommandList * cmd, DWORD time);
RendererCommand(DrawingCommandType cmdID, const deferredFunction_t &function, DWORD time);
RendererCommand(const RendererCommand &rhs);

DrawingCommandType cmdID;
ID3D11CommandList * cmd;
deferredFunction_t deferredFunction;
DWORD time;

RendererCommand DeferredComputeWrapper(const std::function<void (ID3D11DeviceContext*)> &func, ID3D11DeviceContext * context)
ID3D11CommandList * command = NULL;
context->FinishCommandList(FALSE, &command);
return RendererCommand(EDrawingCommand_Render, command, 0);

RendererCommand computeCmd = DeferredComputeWrapper(std::bind(UpdateCompute, width, height,_1), g_pDeferredContext);
Concurrency::send(commandList, computeCmd);
// or even
Concurrency::send(commandList, RendererCommand(EDrawingCommand_Function, std::bind(UpdateCompute, width, height, _1), 2));

Yeah, I think me and VS2010 + C++0x are going to get along just fine... [grin]
Sign in to follow this  


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now