Nish's Blog

For several years I hosted my blog on my personal domain, but it got too tiring to keep maintaining WordPress every time they released a bug-fix or an update. So I finally moved it to WordPress.com.

Recent blog entries

VS14 CTP – Implement Pure Virtuals

This refactoring option implements stub-functions for all pure virtuals in one or all base classes. Here’s an example. If you right click on a specific base class, you’ll get an option to just implement pure virtuals for that class. If you right click on the derived class name, you’ll get the option to implement all […]

VS14 CTP – Move Definition Location

The CTP adds a refactoring option to move a function definition from header to cpp, or vice-versa. Just right-click on the definition, choose Refactor/Move Definition Location and that’s it. Now your code looks like this. You can do the reverse too. There seems to be a bug in this CTP though – when you move […]

VS14 CTP – Create Declaration / Definition

The CTP 2 has a mostly stable implementation of the “Create Declaration / Definition” refactoring tool for your C++ projects. It lets you auto generate the definition or declaration of a member function. Example, if you have a class called Employee, declared in Employee.h and defined in Employee.cpp, you can type in a function declaration […]

VS14 CTP – User-defined literals

User-defined literals is a C++ 11 feature that’s been implemented in the VS 14 CTP. Some of the standard headers have already been updated to define user defined literals. Example, <string> has an s-suffix for string literals. So you can do the following now, and both lines of code are identical. The definition in <string> […]

VS14 CTP – auto return type

Instead of implementing all the C++ 11 features first and then targeting C++ 14, the VC++ team have taken an approach where they will implement both in parallel. This will allow them to implement popular C++ 14 features ahead of less popular C++ 11 features. Either way, at some point, they will have a release […]

VS14 CTP – Inheriting constructors

Inheriting constructors is a C++ 11 feature implemented in this CTP. It extends the using declaration to allow a derived class to indicate that it needs to inherit the base class constructors. Here’s a basic example. You’ll get this error message (as of this CTP). Had Base had a default constructor or if the existing […]

VS14 CTP – Extended sizeof

The Visual Studio 14 CTP is now available as a VM on Azure. The C++ compiler in the CTP has several enhancements for C++ 11 and C++ 14 features. C++ 11 proposes a feature to extend sizeof to apply to non-static data members without needing a temporary object. The CTP implements that feature. Consider the […]

Azure queues – updating messages

The default invisibility timeout of 30 seconds may not suffice on occasions. For those situations, you can change the timeout so that you get more time to do something with your message prior to deleting it. You can also update an existing message. The code snippet below shows how that can be done. One thing […]

Using Azure queues from C++

Azure queues are used to store a large number of items (referred to as messages). Each message can go up to 64 Kb. A typical use for queues is intra-app communication, for example your website might add messages to the queue for a background service to process later on. The C++ Azure storage SDK maintains […]

Downloading blob content

I missed this in the previous blog entry. The SDK makes it really trivial to extract blob data. For text content you can directly get the text, and for non-text content you can either download to a file or to a stream. The code snippet below shows how it’s done.

Using Azure blob storage from C++

Blob storage is for storing large amounts of semi-structured or unstructured data such as images, videos, documents etc. The blob service lets you create named containers that can then contain one or more named blobs which can be publicly (optional) accessed via an URI. Creating blobs The classes/methods used are very similar to that used […]

Writing custom queries against an Azure table

While not as powerful as SQL, Azure tables do allow you to do minimal querying. With the native SDK, you’d do this using the table_query object’s set_filter_string function. Here’s a modified ReadTableData method from the previous blog entries. Here’s an example query that gets all rows within a range of RowKey values. The combine_filter_conditions function […]

Modifying Azure table data

The last blog entry showed how to read data from Azure storage tables. This blog entry will show how to insert, update, and delete data to and from Azure table storage. Inserting data Azure table data is really just about properties. So what’s involved is creating a new table entity, setting up some properties (named […]

Azure Storage access using C++

The Microsoft Azure Storage Client Library for C++ is a library built on top of the C++ REST SDK that lets you access Azure Storage from your C++ apps. You need to install it via NuGet. While installing it, I could not locate it using the NuGet packages UI in Visual Studio 2013. Instead I […]

Using weak_ptr

The weak_ptr holds a weakly referenced pointer to an object that is managed by a shared_ptr (or by multiple shared_ptr instances). The weak_ptr does not affect the strong ref count. You typically construct a weak_ptr out of a shared_ptr, and then when you need to access the underlying object, you call lock() on the weak_ptr […]

Using shared_ptr

While unique_ptr is meant for single-owner scenarios, shared_ptr is the reference counted smart pointer class that allows you to share the smart pointer around your code. Consider the code snippet below, which uses the NumberStore example from the previous blog entry. The output will be: The ref count goes up inside Foo‘s body as Foo […]

Using unique_ptr instead of auto_ptr

I’ve had a bit of a blogging hiatus and hope to make amends for that. Going forward, I will continue to blog on modern C++ features and also focus on newer frameworks from Microsoft (primarily C++ focused, but non-C++ technologies that interest me will also be discussed). For years, we’ve all used auto_ptr with all […]

VC++ 2013 – Initializer lists and uniform initialization

We’ve always been able to use initializer lists with arrays, now you can do it with any type that has a method that takes an argument of type std::initializer_list<T> (including constructors). The standard library collections have all been updated to support initializer lists. And it’s trivial to do this with your own functions. You can […]

VC++ 2013 : Explicit conversion operators

Continuing on with my blog series on C++ 11 support added in Visual C++ 2013, this one’s about explicit conversion operators. I remember a rather embarrassing day in August 2004 when I realized that despite considering myself to be a decent C++ programmer, I had not until then known about the explicit keyword. I have […]

Default template arguments for function templates

This is yet another C++ 11 feature that’s now supported in VC++ 2013. Until now, the following code would not compile with VC++. Visual C++ 2013 compiles this fine, and the template type is inferred correctly. The usefulness of this feature is more evident in the following example. Not all arguments need to have defaults. […]