Skip to main content

Posts

2013


std::unique_ptr usage

·1 min

If you’re new to C++11, this post on Stackoverflow answers the question “How do I pass a unique_ptr argument to a constructor or a function?” going through each case:

  • by value
  • by non-const l-value reference
  • by const l-value reference
  • by r-value reference

Code Smell

·1 min

There is a type of code smell I’ve noticed in C++ code recently, but I would imagine it extends to other languages as well. Consider this class:

class Widget
{
public:
    const std::string Name() const;
    const SomeComplexObject SomeMethod() const;
};

Now consider this class

class Gadget
{
public:
    void ShowName(const Widget & widget) const { std::cout << widget.Name(); }
};

async and await in C++

·1 min

I’ve just watched Herb Sutter‘s talk on C++ in Visual Studio 2013 and onwards.

The last quarter of the talk was concerned with Microsoft introducing the __async and __await keywords in a similar implementation to that already used in C#, note the __ prefix.

As he explained, this is going to be an implementation of a proposed feature for inclusion in a future version of C++, much like the modules feature currently being implemented in CLang.

The Visual Studio roadmap was intertesting, but it looks like we’re going to have to wait a while for generic lambdas.

Rakefiles

·1 min

I thought I would play around with CLang 3.2 on Kubuntu, and needed a quick way to build my code without going through the 1970/80/90s pain of messing around with makefiles and all the associated tab-space nonsense. Rakefiles seemed a good fit.

Setting up a linux distro

·2 mins

Adding a Custom Screen Resolution #

I am running Gnome 2.4 on Debian, and it’s been a while since I’ve hacked an xorg.conf file. So long in fact, that you don’t need to do that any more: you now use xrandr.

Git cheatsheet

·2 mins

Using Git #

Since I’m using git a little bit more often now, this is just a little note to remind me how to do things in git that I would usually do in svn or hg. Yet another git cheatsheet!