March 2013

The Importance of std::function -- Malte Skarupke

See also "Generalizing Observer", written ten years ago when std::function was first adopted.

The Importance of std::function

by Malte Skarupke

... Classically an update loop would be implemented something like this: ...

And this is a good solution at first. But you’ve got that inheritance in there, and that doesn’t scale. You will probably want to add a render loop and maybe a separate update loop for the editor. Once you’ve got that many base classes it makes sense to combine them into one. And now you’ve just started on the way of having a big base class that gets used everywhere. Soon enough adding something different to the update loop involves a whole lot of unnecessary work.

Here is an alternate update loop using std::function: ...

 

Quick Q: How to initialize a const object (say vector) with complex initialization? -- StackOverflow

Quick A: With a lambda function. Try const mytype myobj{ []{ /* compute value */ return value; } }.

How would you initialize a const vector of function results using C++11?

Is it possible to use something like generate_n to create a const vector of, say, random numbers? I couldn't think of a way to do it without deriving vector and doing the assignment in the constructor.

Registration open for C++ and Beyond 2013

This just in on the C++ and Beyond blog... Scott Meyers writes:

Registration for C&B 2013 is open!

C++ and Beyond 2013 will take place December 9-12 at the Salish Lodge and Spa in Snoqualmie, Washington, USA (not far from Seattle). Registration is now open.

Attendance will be limited to 64 people.  (That’s the capacity of the ballroom.) Given that C&B has attracted about 100 people each year, it’s essentially certain that we’ll sell out.  As a result, I encourage you to sign up as soon as you can. Once we sell out, we’ll start a waiting list, but past experience suggests that we won’t be able to offer spots to more than a handful of people on that list.

Early bird registration runs through June 9 and features a 10% discount off the standard registration fee.

Click here to register.

Detailed information about C++ and Beyond is available at its web site:

Andrei and Herb and I hope to see you at C&B 2013 in December!

Scott

C++ and Xcode 4.6 -- from Marshall Clow

Marshall Clow gives some helpful tips for C++ programmers migrating to to XCode 4.6:

C++ and XCode 4.6

So, you’ve installed Xcode 4.6, and you are a C++ programmer.

You want to use the latest and greatest, so you create a new project, and add your sources to the project, and hit Build, and … guess what? Your code doesn’t build!

Continue reading...