C++11: Auto

We've already covered C++11 decltype and why you should start using C++11 features today. Now we will move on to one of the most widely supported C++11 features: the new auto keyword.

auto is supported currently by g++ as of 4.4, clang and msvc since 10. So you are safe using it today if you don't need to support any older compilers.

Are You Using make_shared Yet?

Recently, while watching the GoingNative conference, I learned about the new std::shared_ptr helper function std::make_shared. In the talk Stephan T. Lavavej discusses the performance improvements they've made. It seems std::make_shared can save a few extra allocations and a bit of memory overhead. This can be significant if you dynamically create lots of objects.

Using Non-Standard Resolutions with VirtualBox RDP

I like to connect to Virtual Box guest operating systems remotely over RDP connections. This generally works well except if I connect from my 1280x720 laptop to a Windows guest. In this case the Windows guest will tend to resize to a "standard" resolution that fits inside of the 1280x720, which is 800x600. This can be rather obnoxious.

Trigraphs, Digraphs and Alternative Tokens

Quick, which language is the following code written in?

%:include <iostream>
 
int main(int, char *argv<:??))
<%
  int i = 0;
  int j = 0;
 
  for (; i < 10 and j < 11; ++i, ++j) ??< 
    std::cout << not (i bitand j) << std::endl;
  %>
??>

If you guessed standard C++, you'd be correct. C and C++ support a set of alternative tokens and character sequences to account for languages and keyboards that do not have easy access to characters that those of us with US keyboards consider to be normal.

Trigraph Sequences

Start Using C++11 Now

Every major platform and compiler now supports some aspect of the new C++ standard accepted in 2011. This means it is currently possible to write code that uses some of C++11 while maintaining cross-platform compatibility.

Why should you care?

  1. By enabling C++11 compatibility with your compiler you are future proofing your code. You will be able to catch any portability errors sooner and be ready for the full move.

Double vs. Float, Which is Better?

Neither C++ Coding Standards nor Effective C++ addresses the question of which float point type is best to use and in what situations.

There are three floating point types in C and C++:

  1. float
  2. double
  3. long double

What the Standard Has to Say

There are exactly two guarantees provided by the standard:

Syndicate content