Binary literals

Introduced by: C++14

Until C++14, standard C++ allowed to define numbers in:

  • decimal notation:
    int number = 7;
  • hexadecimal notation:
    int number = 0x7;
  • octal notation:
    int number = 07;

Anyhow, without special compiler extensions it was not allowed to define numbers in binary format. It changes from C++14. The core language supports binary literals. It’s possible to define integer with 0b or 0B prefix to represent binary number.

int number = 0b0111;

It’s worth noticing that the GCC compiler has offered the possibility to define binary numbers since GCC 4.3.

It may be not the most crucial feature of C++ standard, but I believe there are cases when use of binary representation will improve readability of the code.

deprecated attribute

Introduced by: C++14

Attribute deprecated is a new feature of C++14 standard. It can be mostly useful for programmers who develop classes shared between various teams or projects.

When a method of some class becomes obsolete and this class is used only in its owners’ team, it can be just removed and all the occurrences of this function call can be replaced with new valid method calls. This operation becomes unrealizable when the function is a part of shared interface used by various teams. Deleting the obsolete method would be harmful in that case; we cannot know who, where and how often is calling that method and how long they would need to refactor their code to suit new interface. We want to allow them using the deprecated function.

Anyway we would like to tell them somehow that they use the obsolete function and it’s recommended to replace all the calls. And that’s the purpose of attribute deprecated in C++14.

Deprecated in short words

Calling the method marked as deprecated will result in compiler warning. It’s possible to provide custom warning message.

Example of usage

class CSharedInterface
{
public:
    [[deprecated]]
    void run();
};

Calling the method run() will result in compiler warning:
warning: ‘void CSharedInterface::run()’ is deprecated (declared at mainwindow.h:9) [-Wdeprecated-declarations]

Custom warning message can point to new recommended method.

    [[deprecated("use start instead")]]
    void run();

Then the compiler gives warning:

warning: ‘void CSharedInterface::run()’ is deprecated (declared at mainwindow.h:9): use start instead [-Wdeprecated-declarations]

Not only methods can be deprecated; it’s also possible to mark classes, variables, typedefs, enums and other entities.