ReSharper C++ Bloghttps://blog.jetbrains.com/rscpp
ReSharper C++ news, tips, tricks and all things C/C++Fri, 15 Mar 2019 11:44:25 +0000en-UShourly1https://wordpress.org/?v=4.4.18ReSharper C++ 2019.1 EAP meets Unreal Engine 4https://blog.jetbrains.com/rscpp/resharper-cpp-2019-1-eap-meets-ue4/
https://blog.jetbrains.com/rscpp/resharper-cpp-2019-1-eap-meets-ue4/#commentsFri, 15 Mar 2019 10:00:23 +0000http://blog.jetbrains.com/rscpp/?p=905ReSharper has just started an Early Access Program for v2019.1 and there are plenty of great things we plan to add or improve. The ReSharper C++ team has started this year putting the pedal to the metal on performance optimizations … Continue reading →

]]>ReSharper has just started an Early Access Program for v2019.1 and there are plenty of great things we plan to add or improve. The ReSharper C++ team has started this year putting the pedal to the metal on performance optimizations in Unreal Engine 4 codebases. The changes include faster cold startup times, better memory utilization, and new settings to tweak ReSharper’s indexing behavior.

Faster startup times

Depending on the CPU in your workstation, you may expect cold startup to become 5.5 to 6 times faster. This is the time between opening the solution and getting access to the full functionality of ReSharper C++.

Clear the Index third party code and Index plugins checkboxes if you want to skip source files under “Plugins” and “ThirdParty” folders from indexing, or Index Unreal Engine source files to skip the indexing of the engine code altogether.

Note that ReSharper C++ indexes engine code in the background by default. This was already implemented in 2018.3, so here’s just a friendly reminder that you can start working with your game logic code long before the engine code is fully processed. If you turn off background indexing using the Enable background indexing checkbox, this will result in a faster but more intrusive initial indexing.

Let’s make a test!

The following performance test proves the numbers we’ve mentioned above. Using Unreal Engine v4.20.3 and the “Shooter Game” project from the Epic Games Library, we measured the cold startup time for parsing game code and Unreal Engine code, respectively:

Intel i7-8700k: ReSharper C++ cold start time

2018.3:

Game code: 30 sec

Unreal Engine code: 23 min 00 sec

Total time: 23 min 30 sec

2019.1:

Game code: 30 sec (no change)

Unreal Engine code: 3 min 39 sec (6.3 times faster than before)

Total time: 4 min 12 sec (5.59 times faster)

AMD Threadripper 1950x: ReSharper C++ cold start time

2018.3:

Game code: 1 min

Unreal Engine code: 29 min 30 sec

Total time: 30 min 30 sec

2019.1:

Game code: 50 sec
(1.2 times faster than before)

Unreal Engine code: 4 min 16 sec (6.76 times faster)

Total time: 5 min 6 sec (6.08 times faster)

The numbers speak for themselves! Feel free to get the EAP build and take your own measurements on your own Unreal Engine project.

Smaller memory footprint

Besides faster initial indexing, our team has implemented many memory usage optimizations. Both the memory traffic during initial indexing and the memory footprint afterwards have been improved in order to make the IDE more responsive.

Check out the latest ReSharper C++ 2019.1 EAP build and let us know if the IDE performance has improved for you in Unreal Engine 4 projects! As always, your feedback will be greatly appreciated. And there are more goodies coming in this area, so don’t change the channel!

Join us at Game Developers Conference 2019 later in March and chat about Unreal Engine 4 support in our tools!

]]>https://blog.jetbrains.com/rscpp/resharper-cpp-2019-1-eap-meets-ue4/feed/9ReSharper C++ 2018.3: every bit better!https://blog.jetbrains.com/rscpp/resharper-cpp-2018-3-every-bit-better/
https://blog.jetbrains.com/rscpp/resharper-cpp-2018-3-every-bit-better/#commentsWed, 26 Dec 2018 13:29:13 +0000http://blog.jetbrains.com/rscpp/?p=875Please welcome the third release of ReSharper C++ this year! v2018.1 brought debug step filters and includes analyzer, while v2018.2 came with the initial C++/CLI support and better understanding of C++17 and C++20 standards. The just released v2018.3 tunes literally … Continue reading →

]]>Please welcome the third release of ReSharper C++ this year! v2018.1 brought debug step filters and includes analyzer, while v2018.2 came with the initial C++/CLI support and better understanding of C++17 and C++20 standards. The just released v2018.3 tunes literally every smart feature the product has, making them work more precisely on modern C++ code.

Performance improvements meaning a more responsive editor

In this release cycle, we dedicated a lot of time to making ReSharper C++ perform faster:

Memory usage and memory traffic have been optimized, especially affecting indexing and code analysis which are now much quicker.

On project reopening, cache loading is now done in parallel and thus twice as fast, on average.

The Find code issues command and InspectCode command line tool are now parallelized.

We’ve also sped up code completion.

All these changes helped make the editor much more responsive. Try it now and share your impressions with us!

Code formatting

There are dozens of formatter settings in ReSharper C++, available under ReSharper | Options | Code Editing | C++ | Formatting Style. However, wouldn’t it be easier to simply detect the settings from your existing code? Now ReSharper C++ can do that for you! There are several options depending on the scope in which you’d like to detect the settings:

For code opened in the editor, use the menu ReSharper | Edit | Detect formatting settings.

For any specific scope like file, project, or solution, use Detect formatting settings in the context menu in the Solution explorer.

It’s really helpful on dependent code, where it takes template parameter descriptions taken from documentation comments for template arguments:

It also uses default template arguments to provide information about parameters in dependent code:

Besides that, default template arguments are also used to provide code completion in the dependent code:

Name hints

C++ name hints are placed in the editor for function parameters, aggregate initialization, namespace names and macro calls, and they are really helpful to find your way through long (and sometimes nested) lists of parameters, namespaces, etc.

By the way, talking about the name hints at the end of namespace definitions, a neat Clang-Tidy quick-fix can generate a closing comment for you:

Better error diagnostics in templated code

When overload resolution fails in C++, you often get error messages that don’t tell you the exact cause of the problem. The ‘Substitution failed’ error is of little help unless additional details are provided, such as failed enable_if conditions, ill-formed expressions inside decltype, or absent inner types. ReSharper C++ 2018.3 now provides a more specific description of the cause, identifying the exact requirements that aren’t satisfied. Learn more in this detailed blog post.

Change your code reliably

Smarter refactorings

Refactorings are now even more reliable than before. For example, when you refactor members of an anonymous namespace, they are considered unique to their containing file, so the same names in different files do not clash.

When calling up the Change Signature refactoring, you can now choose to make a function constexpr, const, or noexcept, as well as change the ref-qualifiers:

Context actions, inspections, and quick-fixes

To help you quickly make minor changes to your code and improve it, ReSharper C++ provides a set of automatic code transformations called context actions. In v2018.3, the set was expanded with a few very useful actions:

Generate a function implementation and copy it to the clipboard instead of inserting it into the document.

Generate a function that converts an enum to a string.

Convert a regular return type in a function declaration into a trailing return type, and vice versa.

Let’s take a closer look on one particular context action from the list above – generating a function to convert an enum to a string. Printing enum options and making sure you cover all the options might be a non-trivial task. Often, developers come with some macro-based approach to get a generic solution. But what if you can simply generate the required function? In ReSharper C++ 2018.3 you can do that!

The enum_to_string live template used in this code generation is fully customizable: go to ReSharper | Tools | Templates Explorer and find this template in the C++ scope. For example, you can change the live template to generate a stream output operator for an enum:

ReSharper C++ 2018.3 has added many new inspections and quick-fixes. For example, there are new quick-fixes to add a functional-style cast, initialize all uninitialized members/bases, and mark class definition as final.

Upgrading the Clang-tidy integration to use Clang 7 has additionally introduced 50+ new C++ checks.

Navigation updates

We’ve tuned Go to declaration to provide better results in many situations. On a lambda call, it now navigates to the lambda body; it works on non-dependent decltype specifiers, and even works during the initial project indexing. Go to symbol is also available during indexing.

However, the most interesting case is likely using Go to declaration to navigate to unmatched signatures. For example, assume the declaration of a member function was updated. You still can go to its definition with an old signature by using Go to declaration:

In IntelliJ-based IDEs, you can use Ctrl+Click on a declaration to search for usages. Many users find this behavior quite handy, so we’ve added an option in ReSharper and ReSharper C++ to help you configure the behavior you prefer:

Support for Catch2 2.5

Catch2, a unit testing framework for C++, added support for type parameterized test cases in its recent 2.5 version. The idea is that it behaves the same way as a TEST_CASE macro, but tests are run for every type or type combination. The corresponding TEMPLATE_TEST_CASE macros are now supported by ReSharper C++:

Enhanced C++/CLI support

Support for C++/CLI, which originally appeared in ReSharper C++ 2018.2, has been greatly improved in this release. A whole new set of code generation abilities is available for C++/CLI code, including these:

On C++/CLI classes, you can also call the context action create derived class/struct/interface context

The postfix templates new and foreach are available in C++/CLI code

You can also create a field and member function from the actual usage for C++/CLI classes

Other improvements for C++/CLI code include code completion after objects of generic types, additional filters in Search Everywhere dialog for events and properties, correct handling of inheritance in C++/CLI, and more.

Enhanced Unreal Engine support

If you work on Unreal Engine projects, you can now start typing or navigating through your project seconds after you open it! To make this possible, we postponed engine indexing, which now starts in the background after the non-engine code is parsed.

Another notable change is improved support for Unreal Engine reflection macros such as UCLASS, USTRUCT, UENUM, and so on. They are used to emulate reflection, which is missing from the C++ language. You no longer have to build your Unreal Engine project to resolve these macros correctly!

Visual Studio 2019 Preview 1 support

Starting with v2018.3, you can use ReSharper (and ReSharper C++) with the Visual Studio 2019 Preview 1 build. Full support will be available in future ReSharper updates after Visual Studio 2019 is released officially.

That’s it! Give ReSharper C++ 2018.3 a try and share your feedback with us in the comments below, in our tracker, or on the support forum. We’re waiting to hear from you!

]]>https://blog.jetbrains.com/rscpp/resharper-cpp-2018-3-every-bit-better/feed/2When an error message is worth a thousand wordshttps://blog.jetbrains.com/rscpp/error-message-worth-thousand-words/
https://blog.jetbrains.com/rscpp/error-message-worth-thousand-words/#respondTue, 20 Nov 2018 15:22:13 +0000http://blog.jetbrains.com/rscpp/?p=863ReSharper C++ is currently running its Early Access Program for v2018.3, which already has a few important enhancements to offer: C++/CLI support has been improved with several new context and generate actions for C++/CLI code. Solutions are loaded a lot … Continue reading →

C++/CLI support has been improved with several new context and generate actions for C++/CLI code.

Solutions are loaded a lot faster, especially those that use the Unreal Engine. The main catch is that ReSharper C++ only parses non-engine projects during the initial indexing; the engine files are indexed in the background later.

Predefined naming schemes for common C++ code standards were introduced.

Refactorings, code generation, formatting, and other areas have been enhanced in various ways.

Among these improved areas, there’s one we’d like to talk about in more detail. The error annotator in ReSharper C++. These improvements are available in the recently published 2018.3 EAP 6 build. Let’s see what it’s all about!

When the overload resolution fails in C++, you often get error messages that don’t tell you the exact cause of the problem. Messages like ‘Substitution failed’, ‘Couldn’t infer substitution’, or ‘no instance of function matches the argument list’ are of little help unless additional details are provided:

An error message like that does give you some hints, suggesting that probably the argument used in your template function call is wrong. Still, it doesn’t say which specific requirements were not satisfied. Figuring things out gets even more complicated if the template code is located far from where the error occurs.

For example, in the code sample above, it would be much easier to pinpoint the problem if the error explicitly said that there was no type named inner_type in struct Y. This is actually what compilers like clang (7.0) or GCC (8.2), and now ReSharper C++ will tell you:

Another example is when the substitution fails because a member is missing:

Starting with the latest EAP build, ReSharper C++ will now warn you about this pattern, pointing out the particular ill-formed expression that uses the missing member in the template.

Better error messages for enable_if

ReSharper C++ will show a similarly useful error message when enable_if is used to conditionally remove functions from the overload resolution set. Knowing which specific condition is not satisfied, you can debug your code more easily.

In the example below, ReSharper C++ will understand that the is_integral requirement fails (instead of just saying that ‘No instance of the overloaded function matches the list’):

Another example of this kind is when the is_default_constructible condition is not satisfied:

In another interesting case, Visual Studio 15.8 extended std::pair with one more default constructor (an explicit one). Well, ReSharper C++ checks all the candidates and tells you in every why they don’t fit:

As you can see from the screenshot above, other overloads are also listed in addition to the candidates considered.

Finally, here’s where we think ReSharper C++ does an even better job than all the three major compilers (Microsoft Visual C++, Clang and GCC):

For this piece of code, MSVC provides ‘no instance of function template “do_stuff” matches the argument list, argument types are: (int, int)’ message, while Clang shows a more reasonable error, namely ‘requirement ‘std::conjunction_v, std::is_floating_point >’ was not satisfied [with T = int, U = int]’. But ReSharper C++ does it one better: it shows the argument that broke the substitution ((int)2) and the condition that was not fulfilled (is_floating_point::value)!

Check out the latest ReSharper C++ 2018.3 EAP build and let us know if this enhanced error annotator helps you resolve substitution failures in your code! Your feedback will be greatly appreciated, as always.

While ReSharper C++ 2018.1 introduced two major new features, debug step filters and includes analyzer, ReSharper C++ 2018.2 is focused on improving its understanding of the C++ language. The biggest highlight is its long-awaited support for C++/CLI. In addition, many important features from C++17 and even the upcoming C++20 have been implemented. Code analysis is enhanced with spell-checking inspections powered by the newly bundled ReSpeller plugin, as well as formatting inspections to help you maintain a consistent code style.

Initial C++/CLI support

C++/CLI is a set of C++ language extensions by Microsoft designed for easy interoperability between managed and native code. With extensive support for both managed languages and C++, it is only natural for ReSharper to offer help with writing code in C++/CLI too.

Generics, value and ref classes, handles, tracking references, and interfaces are just some of the new language constructs in C++/CLI introduced to support managed semantics. With so many syntactic additions and peculiar changes to the C++ language, handling C++/CLI is no easy task. But now the wait is over — ReSharper C++ 2018.2 makes its C++/CLI support public, with many major features (including code inspections, typing assistance, formatting, and code completion) updated to support this language dialect.

Please remember that this section is named “Initial support” for a reason, and our work on C++/CLI is by no means done. To name just a few limitations: #using directives are not supported, auto-import does not work for CLR classes, and class hierarchy navigation features have limited functionality. While Find Usages and Go To Declaration will work between C++/CLI and C#, refactorings like Rename cannot cross the language barrier yet. The entire list of active issues is available in YouTrack.

C++/CLI is a unique beast. It is used mostly in enterprise projects and in-house codebases, so the number of open source projects that rely on it is very small. This means that we do not have a significant number of available projects to test on. As we move to expand our coverage, we would love to hear your feedback on what is missing and what you feel we should concentrate on.

Note that C++/CLI support requires a ReSharper Ultimate subscription and the ReSharper product to be enabled. If you find that you want to fall back to bare Visual Studio when editing C++/CLI sources, you can disable C++/CLI support in ReSharper C++ completely using the Enable C++/CLI support option on the Code Editing | C++ | Inspections option page. To learn more, see C++/CLI support comes to ReSharper C++.

C++17 features

Another area that we have been putting a lot of effort into is our ongoing work on C++17 support. ReSharper C++ 2018.2 adds understanding of the following new features:

Class template argument deduction (P0091) lets you omit explicit class template arguments if they can be automatically deduced from constructor arguments.
You can also specify how to deduce class template arguments from constructor arguments yourself via user-defined deduction guides. As an example, by using a custom deduction guide, you can enable template argument deduction for a constructor of a container class which accepts a pair of iterators:
The standard library uses a similar approach with its containers.

Fold expressions (N4191) are a new kind of expressions inside variadic templates. The aim of fold expressions is to provide a simple way to apply binary operators to parameter packs. Here is how you can calculate a bitmask in C++17 using a unary right fold expression:

Auto non-type template parameters (P0127) let you indicate that the type of a non-type template parameter should be deduced at the point of instantiation. One interesting application of this feature is variadic templates which accept a list of heterogeneous constant values as template arguments:

With pack expansions in using declarations (P0195), it is now possible to introduce a name from a pack of classes inside a variadic template. The following snippet, which uses both this feature and class template argument deduction, shows how easy it is in C++17 to overload over a set of lambda objects:

Using declarations with multiple declarators is a straightforward change to the syntax of using declarations, which lets you introduce several names in the same declaration.

Some say that guaranteed copy elision is the most significant language change in C++17. The standard legalese in P0135 is complicated, but in a nutshell it means that copy elision in several specific contexts is now mandatory. In practice, the biggest change is that you can now return non-copyable and non-moveable objects (like std::mutex) from a function by value.

The definition of an aggregate type has been extended in C++17 to allow non-virtual public base classes (P0017). This means that you can now use aggregate initialization with such classes:

std::is_aggregate is a new type trait introduced in C++17 as a way to check whether a type is an aggregate type.

__has_include (P0061) is a builtin preprocessor macro which can be used to portably determine whether or not a library header is available for inclusion. For example, here is how you can select a coroutine-based generator either from the standard library if it provides one or from CppCoro:

With the progress done over the course of the previous releases (see our updates about C++17 support in 2017.1, 2017.2, and 2017.3), these changes mean that most of the major C++17 features are now supported by ReSharper C++. The biggest gaps that we are going to focus on next are limited support for evaluation of constexpr functions (RSCPP-18417), hexadecimal floating point literals (RSCPP-20364), and noexcept as a part of the function type (RSCPP-20285).

C++20 features

While it’s too early to say for sure which changes are going to make it into C++20, the new standard is already shaping up and its features are becoming available in major compilers. Keeping up with the evolution of the language, ReSharper C++ now supports several features from the upcoming standard:

Even though coroutines have not been officially accepted into C++20 yet, the Coroutines TS is already implemented in both MSVC and Clang and is used by many real-world projects.
ReSharper C++ understands and resolves all the new syntax introduced by the proposal, including co_await and co_yield expressions, co_return statements, range-based for co_await loops, and operator co_await. If you invoke Go to Declaration on a coroutine expression or statement, ReSharper C++ will let you navigate to all the functions which are called behind the scenes by the low-level coroutine machinery.
Remember that you need to use the /await compiler switch to enable coroutines support. Please note that the <experimental/generator> header provided by Visual Studio does not fully conform to the latest Coroutines TS draft. If you need a library of coroutine-based abstractions, we recommend using the excellent CppCoro library by Lewis Baker.

Designated initialization (P0329) introduces a new syntax based on C99 to initialize an aggregate class using explicit names of data members.

Similar to if and switch statements with initializer from C++17, range-based for statements will allow an initializer block in C++20 (P0614). This change lets you create a declaration with the same lifetime as the for loop.

Feature test macros (P0941) are a set of predefined macros which can be used to check in a portable way if a particular language feature is supported. They complement the C++17 __has_include macro.

Bit-fields can now have default member initializers (P0683), similar to normal class members.

Integrated spell checking with ReSpeller

ReSharper C++ 2018.2 provides spell-checking functionality out of the box, thanks to the newly bundled ReSpeller extension which has also been updated to support the C++ language. Just like with code analysis, ReSpeller scans for spelling mistakes and typos in identifiers, comments, and string literals, and provides quick-fixes to resolve these problems.

When you encounter a spelling mistake, you can invoke the Alt+Enter menu and ReSpeller will provide two options to fix the mistake:

The first option is to fix the typo. If the typo was in the name of symbol, the Rename refactoring will be automatically invoked. If the rename operation is local, you will get a list of proposed corrections in a dropdown menu. With a global rename operation you will need to clear the Name field and invoke completion with Ctrl+Space to get the same list.

The second option is to add the unknown word to ReSpeller’s dictionary. As with other preferences, you can choose one of the settings layers to save the word to.

Code understanding is what really makes spell-checking stand out in ReSharper C++ compared to other Visual Studio extensions. If ReSpeller encounters a mistake in an identifier name, it will only be reported at the declaration point. Documentation comments are handled in a special way too, so that Doxygen commands are skipped. Furthermore, the Environment | ReSpeller options page allows you to make ReSpeller skip locals, overriding member function, or class members with specific accessibility.

Formatting inspections

Every now and then, you want to be notified directly in the code when you are not following formatting rules. With this in mind, ReSharper C++’s code formatting engine introduces inspections and quick-fixes for formatter-related problems: inconsistent indenting, line breaks, spaces, and blank lines can now be observed and fixed directly in the code editor.

By default, formatting inspections are disabled so as not to bother anyone who doesn’t care about formatting during typing. Go to ReSharper | Options | Code Inspection | Inspection Severity | C++ | Formatting to see all the available inspections and select severity levels for those you wish to be notified of.

Parameter Info provides details about members of the aggregate class when performing aggregate initialization.

Comments in a code file to override formatter settings can be generated directly from the Configure Format dialog.

You can navigate to the begin() and end() functions used in a range-based for loop by invoking Go To Declaration on the colon character.

Separate color settings for static class fields and static member functions were added. You can customize them by going to the Fonts and Colors Visual Studio options page and changing two display items, ReSharper C++ Static Field Identifier and ReSharper C++ Static Member Function Identifier.

A lot of performance fixes in different areas of ReSharper were made, from speeding up ClangFormat support to decreasing solution loading time. More detailed information is available in the performance blog post series dedicated to the ReSharper 2018.2 release.

200+ issues were fixed over the course of ReSharper C++ 2018.2 development, including two important issues where ReSharper C++ could sometimes fail to parse files with complicated macro expansions, and where it missed some usages when performing usage search.

CppCon 2018

ReSharper C++ is coming to CppCon 2018, the premier C++ conference! Please stop by the JetBrains booth to have a chat about our products and grab some cool swag, and consider attending one of the many talks presented by our colleagues:

]]>https://blog.jetbrains.com/rscpp/whats-new-in-resharper-cpp-2018-2/feed/0C++/CLI support comes to ReSharper C++https://blog.jetbrains.com/rscpp/cli-support-comes-to-resharper-cpp/
https://blog.jetbrains.com/rscpp/cli-support-comes-to-resharper-cpp/#commentsSat, 21 Jul 2018 19:58:36 +0000http://blog.jetbrains.com/rscpp/?p=743ReSharper C++ joined the ReSharper fold back in 2015 to bring the power of ReSharper to the world of C++ – and has been getting better ever since! For most people this has rounded out the ReSharper story within Visual … Continue reading →

]]>ReSharper C++ joined the ReSharper fold back in 2015 to bring the power of ReSharper to the world of C++ – and has been getting better ever since! For most people this has rounded out the ReSharper story within Visual Studio. However an odd gap remains. Odd because the worlds of C++ and C# are bridged by the interop language, C++/CLI, yet this has remained unsupported by the ReSharper family.

Until now, that is!

From 2018.2 (available now in the EAP) ReSharper C++ has initial support for C++/CLI. There are some limitations, so read on to find out more. Support is enabled by default, but can be disabled by going to ReSharper | Options | Code Editing | C++ | Inspections, and unchecking “Enable C++/CLI support”. But we hope you won’t do that – especially as we’re also looking for user feedback and greater field experience.

A peculiar beast

As a rule nobody uses C++/CLI as a primary language. That’s not what it’s been designed for. While C# is a highly productive language, and is no slouch when it comes to performance, there are many reasons that we may also have a parts of our project written in pure C++. C++/CLI is an answer to the question, “how do I get to, or from, my pure C++ from C# (or any .NET language)?”. If you just need to call into C++, and it exposes a C API, P/Invoke may be the simplest way to go. But for more complex cases – where you want to model richer types and class hierarchies – C++/CLI let’s you do that. But it comes at the cost of a more complex language, with curious syntactic additions and sometimes tricky lifetime issues. So any help we can get from our tools while writing and maintaining this code is very welcome.

What is supported?

ReSharper C++ 2018.2 gives us initial support for C++/CLI projects. What does that mean? Well first it means that the parser and resolver now finally understand the extension system, with ^’s for CLR references, gcnew for allocating on the managed heap, etc. It also means that many static analysis features now work and can give us valuable insight. Note that, at time of this writing, there may still be a few limitations here. Please report these in our issue tracker so we can address them as quickly as possible.

Within C++/CLI code we have access to all the same great refactorings and intention actions as in pure C++ code. For example postfix templates are a great way to rewrite statements around a value. Where applicable these should work across C++/CLI and pure C++ codebases – for example you can rename a pure C++ symbol, or even a C# symbol, from within a C++/CLI usage. Again, some limitations may apply.

We can also navigate between C# and C++/CLI worlds. For example if we place the caret over a C++/CLI method name in some C# code you can now navigate to the definition in the C++/CLI code (note that this is referred to as “Go to declaration” in the menu, due to how these terms are used in C#). You can do the same going the other way, too.

For now there are some known limitations here. For instance from a C# project in the same solution, renaming a C++/CLI symbol is not an option. From the C++/CLI project, renaming a symbol referred to by the C# project wll rename it within the C++/CLI code, but not in the C# project. As mentioned already, renaming a native C++ symbol from a C++/CLI project works as expected, however.

Code generation is also limited for now, as generators for C++/CLI specific constructs, such as ref classes, have not yet been written. And the #using directive (for importing metadata in directly from a dll) is not supported at all – meaning both the use of the #using directive, as well as any symbols referenced from the dll, will currently be flagged as errors by the analyser.

We need your help

C++/CLI is unique in many ways. Software projects that make use of it tend to be larger enterprise style projects of in-house code bases that cannot be shared outside the organisation. There is very little in the way of non-trivial open source projects using C++/CLI. Here at JetBrains we only use it in some small ways internally to the ReShaper C++ implementation. So it is particularly difficult to build realistic test cases. As we move to expand our coverage we’ll rely a lot more on the community to tell us what’s not working (of course we’d also love to hear what’s working, too!) so we can do our best to address it and make our C++/CLI support first class.

]]>https://blog.jetbrains.com/rscpp/cli-support-comes-to-resharper-cpp/feed/6Analyzing includes with ReSharper C++https://blog.jetbrains.com/rscpp/analyzing-includes/
https://blog.jetbrains.com/rscpp/analyzing-includes/#respondTue, 05 Jun 2018 16:05:27 +0000http://blog.jetbrains.com/rscpp/?p=735Hi, Last week we published a detailed overview of ReSharper C++ 2018.1 changes. One of the major features for this release is Includes analyzer, a tool for locating and eliminating unnecessary header dependencies and thus upping compilation speeds. You can … Continue reading →

Last week we published a detailed overview of ReSharper C++ 2018.1 changes. One of the major features for this release is Includes analyzer, a tool for locating and eliminating unnecessary header dependencies and thus upping compilation speeds. You can read about it in detail in this blog post. Today though, we’d like to give you a short demo recorded by Phil Nash, our C++ tools developer advocate. Watch the Includes analyzer in action and download the free 30-day trial of ReSharper C++ to try it on your project:

If you find Includes analyzer useful or have questions or comments about it, please use the comment section below or our issue tracker to share your feedback with us. We’ll be glad to know what you think!

]]>We are pleased to introduce ReSharper C++ 2018.1, our first major update this year!

This release comes with two new important features. First, Debug Step Filters lets you avoid stepping into specific functions during debugging. Second, Includes Analyzer helps investigate the dependencies between header files that affect build times. Read on for more details about these features and other highlights of the 2018.1 release:

When you invoke Step Into, the Visual Studio debugger will normally step into all the functions that are called from the current statement. However, there are functions (like simple getters, setters, or dereference operators), which are either trivial or so well tested that you never want to step into them. This is where step filters come in: with this feature, you can specify the functions that should always be stepped over.

A step filter is defined by a regular expression, which is matched against the name of the function that the debugger is stepping into. You can inspect, configure, disable, or enable back step filters on the Tools | Debugging | C++ options page, which lists all the available filters.

ReSharper C++ comes with a predefined collection of step filters for the standard library, but you can easily add your own. You can come up with a custom regular expression that matches the names of functions to step over and manually add a filter from the options page. Or you can have ReSharper C++ automatically create one during a debugging session.

When you step into a function and decide that you want to step over it in the future, you can use a context action to quickly add a new step filter. For template functions, there are separate context actions to add either only the current instantiation of the function template or all of its instantiations. If a matching filter has already been added to the list but was temporarily disabled, a context action will be available to enable it back.
The filters are stored using ReSharper’s layered settings. By default, the action to add a new filter follows the Smart Save logic, but you can use the action’s submenu to choose the layer to which the filter should be saved to. For example, you can use the Solution team-shared layer to make the new filter available to your teammates.

You might remember that Visual Studio has a built-in way to customize stepping behavior in C++, which is a part of C++ Just My Code. However, no user interface is provided for configuring this feature from the IDE, so you need to manually edit .natstepfilter XML configuration files to change existing or add new rules. Furthermore, there is no way to add solution-specific rules, since the configuration files are global. Please note that at the moment Visual Studio’s support for .natstepfilter files gets disabled if ReSharper C++ is installed.

Includes analyzer

Long build times is one of the biggest problems in large real-world C++ projects. ReSharper C++ already has a few tricks up its sleeve to aid you. For example, it will mark unused #include directives or automatically create forward declarations for unresolved names instead of simply including the headers with the required declarations.

ReSharper C++ 2018.1 introduces Includes Analyzer, a brand new code inspection tool that helps you speed up the compilation process.

Includes Analyzer is meant to help you locate and eliminate unnecessary header dependencies. A typical project might contain many thousands of #include directives, and it’s not clear which of them are worth investigating. Includes Analyzer attempts to estimate the contribution of each header file to the build time, based on the number of lines of code that it adds to the total compilation workload. While this is not a precise metric, it’s a useful starting criterion which can help you find and prioritize the most included header files.

After you identify the header dependencies that potentially have the biggest impact, you can try getting rid of them one by one via the standard approaches. These include: using forward declarations wherever possible, removing unneeded #include directives, applying the Pimpl idiom, splitting header files into smaller ones, and so on.

To start the analysis, invoke one of the ReSharper | Inspect | Analyze Includes in… actions from the main menu, or select Analyze Includes from the Solution Explorer context menu.
ReSharper C++ will analyze the files in the given scope and present a report in a dedicated tool window, where you can explore the dependencies between the files. The Includes analysis window provides two separate views, Includees and Includers, both of which present include dependencies as a tree where each node corresponds to a file. You can switch between the views via the corresponding toolbar buttons, or by navigating to the same file in the other view from the context menu.

The Includees view helps you understand how many lines of code the header file in a top-level tree node contributes to all source files that directly or indirectly include it. Child nodes in this view represent files that include the file from the parent node. Consider the following analysis of the entire Catch2 solution:
There are three metrics for each node in the tree:

Times included shows how many source files include the header in the top-level node through the path to the current node. In the example above, catch_common.h was included into 75 source files in total, of which 26 included catch_common.h through the #include "catch_common.h" directive in catch_tag_alias_autoregistrar.h.

Line contribution shows how many lines of code the header in the top-level node contributed through the path to the current node by itself, without transitively included files. catch_common.h contributed 4,050 lines of code in total, which is 75 (the number of source files that include it) times 54 (the number of lines of code in the file). Out of 4,050 in total, 1,404 lines were contributed because of #include "catch_common.h" in catch_tag_alias_autoregistrar.h.

Line contribution inclusive is similar to Line contribution, but this metric takes into account all headers transitively included into the file in the top-level node. E.g. catch_common.h, together with the headers included into it, contributes 2,654,938 lines in total during compilation of the entire solution. 1,017,626 of those lines were contributed because of #include "catch_common.h" in catch_tag_alias_autoregistrar.h. Line contribution inclusive is the default and arguably the most useful sorting criteria.

The Includers view is similar to the Includees view, but acts in the opposite way: the child nodes inside the tree represent files which are included into the file from the parent node.
This view shows how many lines of code are transitively included into the file in a top-level node as if it was compiled as a standalone source file (e.g. catch_common.h together with all headers included into it comprises 42,365 lines of code, of which 27,046 were brought with #include <string>). The metrics that this view provides are Includee count (the number of included files), Line count (the size of the file itself), and Line count inclusive (the size of the file with all the header files it includes).

One important limitation of Includes Analyzer is that ReSharper C++ does not actually run a full preprocessing stage in order to speed up the analysis process. This means that the line count does not in fact include the results of macro expansions, and that include guards do not get handled as well. Instead, ReSharper C++ assumes that each header file starts with an include guard or a #pragma once directive, and gets included at most once in any source file. Each successive include of the same header does not count towards its number of contributed lines, which means that sometimes you may encounter Times included and other metrics equal to zero next to an internal tree node.

In addition to navigation controls and the refresh button, the toolbar in the Includes analysis window lets you change two options:

Show only root nodes belonging to some project will hide top-level tree nodes that correspond to files not belonging to any project. This is a quick way to filter out library files if you want to concentrate only on headers inside your solution.

By default, ReSharper C++ skips blank lines and comments during an analysis. The Count blank and comment lines button lets you change this behavior.

We would like to give a shout-out to Header Hero, which inspired our own implementation of the same underlying idea. Check out the Caring by Sharing: Header Hero blog post, which introduces this great little tool and gives a few tips for improving project build times.

Navigation improvements

ReSharper C++ 2018.1’s biggest navigation update is the redesigned Go to File Member (Alt+\) dialog.
We have updated the dialog in several ways:

Class members in the open file are now grouped by their containing class in the results list.

With no search string active, file members are sorted in the order of their declarations inside the file.

The scrolling list with the results accommodates more items.

Together, these updates make the dialog more usable as they provide clearer insight into the structure of the current file.

In all Go to dialogs and several other places, ReSharper C++ now attempts to shorten symbol names that are excessively long, by omitting function and template parameters.

When you perform a search using the Recent Files dialog (Ctrl+,), Go to File search results are also appended to the results list after the Recent File items.

Finally, the option to remember the last search in the Search Everywhere dialog is now on by default. You can revert to the old behavior through the Environment | Search & Navigation | Remember last search setting.

Command-line code cleanup

ReSharper Command Line Tools, a free standalone collection of tools that can be used from the command line or as part of the continuous integration process, can now perform code formatting and cleanup in C++ projects. This instantly eliminates code style violations in a project or solution, and helps ensure a uniform code base.

To run the code cleanup tool on your solution, invoke cleanupcode.x86.exe from the command-line tools distribution with the path to the solution file. It will automatically reformat your code, fix common code style violations, remove redundant code, and optionally apply Clang-Tidy fix-its.

By default, command-line tools will use the predefined Full Cleanup profile, which includes the formatting stage and most (though not all) fixes for common code style issues, but skips the Clang-Tidy analysis stage. The other built-in profile is Reformat Code, which will apply only code formatting preferences. To use it, pass the profile name via the --profile command-line argument of cleanupcode.x86.exe:

ReSharper 2018.1 also fixes bogus errors which were output by the InspectCode tool on x64 projects. In addition, the upcoming 2018.1 release of TeamCity is able to run InspectCode on C++ projects (see TW-48978 for details).

Code inspections

ReSharper C++ 2018.1 adds several new built-in inspections:

A new inspection (with a corresponding fix and a code cleanup item) suggests replacing if statements with if constexpr when the condition is a compile-time constant expression.

Attempted usages of deleted functions are now diagnosed as errors, including usages via implicit function calls.

A new inspection warns about overriding destructors without the override specifier. There’s still debate in the C++ community whether destructors should ever be marked with override (for example, C++ Core Guidelines recommend against doing that), so the inspection is turned off by default. If you wish to use this inspection, please enable it on the Code Inspection | Inspection Severity options page.

Control flow and usage checking analyses have been updated to handle lambdas. This means that all the related inspections (unused variables and function parameters, unreachable code, redundant jumps, and many others), that previously worked only with functions, are also now available inside lambda bodies.

Finally, a minor change fixes the interaction between the Declarator is never used inspection and C++17 structured binding declarations. Previously, ReSharper C++ warned you about each unused structured binding separately from all the other bindings in the same declaration. We’ve changed this behavior so that if at least one of the structured bindings is used, the inspection does not trigger on any of the bindings.
Now all the major C++ compilers follow this logic, including MSVC starting with the update shipped in Visual Studio 15.7. If none of the bindings are used, you can still use the [[maybe_unused]] attribute to silence the inspection, but in practice you probably won’t ever need to.

More ways to configure inspection severity

In previous ReSharper C++ releases, inspection severity could only be set for the entire solution. But it is often required to be able to configure severity settings independently in different parts of the codebase, for example in legacy or test projects. In ReSharper С++ 2018.1, you can optionally enable the ability to have separate severity settings via the Read settings from EditorConfig and project settings option on the Code Inspection | Settings | General options page.

With this option turned on, you can set custom inspection severity using one of two approaches:

EditorConfig files. ReSharper C++ inspection severity can be specified inside an EditorConfig file using resharper_[severity id]_highlighting properties, where [severity id] is the name of the severity spelled in lower case with underscores. Depending on your needs, you can assign any value of do_not_show, hint, suggestion, warning or error to the property.

EditorConfig supports wildcard patterns in filenames, which means that inspection severity can be set independently even for specific files. A previous blog post entitled Configuring inspection severity with EditorConfig goes into more detail about using EditorConfig files, but do remember that you need to enable the option Code Editing | General Formatter Style | Enable EditorConfig support in order to have EditorConfig available.

Please note that enabling granular inspection severity might have a noticeable performance impact on the speed of code analysis, depending on your configuration and the number of issues in a given file.

Clang-Tidy integration updates

Clang 6.0 was released this March. To keep up, we have updated the Clang-Tidy binary bundled with ReSharper C++, with several user-visible changes:

Another new Clang-Tidy feature from the 6.0 release is the extended syntax of the NOLINT comment, which now accepts an optional list of check names to silence. ReSharper C++ adds a new inspection action that utilizes the new syntax and lets you disable a specific Clang-Tidy diagnostic on the current line:

We have also received several reports of Clang-Tidy crashes, with Windows displaying crash notifications as a result. While the ReSharper C++ team cannot fix the crashes themselves, we have changed the default error reporting mode used by the clang-tidy binary to prevent the annoying message boxes.

Other changes

Unit testing support includes two minor updates:

ReSharper C++ 2018.1.1 fixes compatibility with Boost.Test from Boost 1.67 (which was broken because of a bug in Boost.Test).

If you select an expression and open the Quick Documentation window, it will show various information about the selected expression, such as its type, value, and value category. You can use this ability, for example, to quickly evaluate a type trait for a specific type:

If you’d like to learn more about how C++ tools can improve your development workflow, Anastasia Kazakova (C++ tools PMM at JetBrains) recently gave a talk at the ACCU 2018 conference entitled Debug C++ Without Running. In her talk, Anastasia discusses a few peculiarities of the C++ language that contribute to its notorious complexity and demonstrates some helpful features from ReSharper C++, CLion, and other C++ tools.

Some functions never need to be stepped into because they are either very simple or very well tested. But the problem is that the debugger cannot tell which functions are worth debugging and which aren’t, and therefore Step Into will not miss any user function on its way.
Visual Studio’s Just My Code functionality takes basic care of this problem by ignoring non-user code and letting you customize ignored symbols using text config files.

However with ReSharper C++, you can now visually maintain step filters — a list of function masks that tells the debugger what should be skipped on stepping. By default, this list includes a lot of library functions and it can be extended.

Of course, ReSharper wouldn’t be ReSharper without having some handy goodies here: to quickly add a function to the filters, you can press Alt+Enter on that function while debugging and pick the corresponding action:

The filters are stored using ReSharper’s layered settings. By default, the action saves the filter in the ‘Solution personal’ layer, but you can use the action’s submenu to choose where the filter should be saved — e.g in the ‘Solution team-shared’ layer, so that this filter will be also available to your teammates.

You can study and further configure step filters on the Tools | Debugging | C++ options page:

]]>https://blog.jetbrains.com/rscpp/step-filters-resharper-cpp/feed/9What’s New in ReSharper C++ 2017.3https://blog.jetbrains.com/rscpp/whats-new-resharper-c-2017-3/
https://blog.jetbrains.com/rscpp/whats-new-resharper-c-2017-3/#commentsWed, 21 Feb 2018 11:16:23 +0000http://blog.jetbrains.com/rscpp/?p=532ReSharper C++ 2017.3 has been one of our biggest updates yet in terms of both new features and fixed issues. Without further ado, let’s dig into the notable changes it brings: Clang-Tidy integration Debugger features Language understanding Code inspections and … Continue reading →

Clang-Tidy integration

Clang-Tidy is a powerful open-source code analysis tool based on the popular Clang compiler. It comes with an extensive set of code checks and accompanying fixes for typical programming errors.

ReSharper C++ 2017.3 provides seamless integration with Clang-Tidy. This means that as you edit a file, ReSharper C++ runs Clang-Tidy on it in background as a separate process, with inspection results shown right in the editor alongside other ReSharper C++’s inspections. Unsaved files are handled transparently by saving the text of the current document to a temporary file and instructing Clang-Tidy to use it instead of the on-disk version.

To distinguish between Clang-Tidy checks and ReSharper C++’s inspections, look at the name of the check in square brackets, appended to the inspection message.

In addition to diagnostics from Clang-Tidy checks, Clang-Tidy also issues diagnostics from Clang Static Analyzer and warnings provided by the Clang compiler itself. All of them have corresponding ReSharper inspections with configurable severity levels, which can be adjusted to meet your needs on the Inspection Severity options page.

Some of the Clang-Tidy checks that duplicate ReSharper C++’s built-in inspections are turned off by default. In addition, all static analyzer checks are disabled, since enabling them significantly slows down Clang-Tidy.

As with the built-in inspections, you can use the inspection context menu to quickly change the severity of a Clang-Tidy check, or to disable it via a comment. There is also an additional action that opens the online documentation page for a particular check.

ReSharper C++ lets you apply the fixes provided by Clang-Tidy similarly to its own built-in quick-fixes. As with other bulk fixes, Clang-Tidy fixes can be applied individually or inside a specific scope (file, folder, project, or solution).

By default, ReSharper C++ will reformat code changed by Clang-Tidy to maintain the code style. This behavior can be disabled via the Reformat changed code after applying Clang-Tidy fix-its setting to speed up fix execution.

Clang-Tidy fixes can also be applied from code cleanup. Built-in code cleanup profiles do not include the Clang-Tidy stage, so to enable it you need to create a new profile and select the Clang-Tidy checks which will be enabled during a code cleanup run.

The selected checks will be enabled even if they are turned off on the Inspection Severity options page. Please be careful when enabling too many checks at once — code cleanup runs Clang-Tidy only once for a given file, so if multiple fixes touch the same block of code, the changes might conflict with each other.

ReSharper C++ does not write its own Clang-Tidy config, so a user-provided one can be picked. Clang-Tidy attempts to read configuration for each source file from a .clang-tidy file located in the closest parent directory of the source file. The source file here (as with the rest of ReSharper C++ inspections) is the .cpp file itself if the analysis is run on it, or a random .cpp file which includes the header when the analysis is performed on a header file. Alternatively, you can use the Clang-Tidy config ReSharper setting to pass a string with custom configuration to Clang-Tidy via the -config command-line option.

The -checks command line option is used to pass the list of enabled checks to Clang-Tidy, which then gets appended to the value of the checks option read from the Clang-Tidy config. To construct the -checks argument, ReSharper C++ takes the value of the List of enabled/disabled Clang-Tidy checks and appends to it the names of checks which are turned off on the Inspection Severity options page.

We needed to make a few modifications to Clang-Tidy to facilitate its usage from the IDE, so unfortunately a custom Clang-Tidy binary cannot be used at the moment. ReSharper C++ 2017.3 is shipped with a version of Clang-Tidy built from the trunk, and we plan to update it to the final Clang 6.0 version in ReSharper C++ 2018.1.

There are a few caveats to Clang-Tidy integration that we are aware of:

Files using UTF-16 or UTF-32 encoding cannot be read by Clang and thus are not supported by Clang-Tidy at the moment.

Sometimes Clang-Tidy might crash on your code, and Windows will show you the “Process has stopped working” message. In this case please disable Clang-Tidy integration for the current solution (see how below). We’ll update the bundled binary in 2018.1 so that this message is not shown.

There are several ways to disable or enable Clang-Tidy integration:

Via the Enable Clang-Tidy support setting in ReSharper options.

Through the Enable Clang-Tidy analysis toggle in the status indicator context menu:

With the Ctrl+Shift+Alt+9 keyboard shortcut.

Debugger features

ReSharper C++ 2017.3 is the first release that brings debugger-related features to the table. The most useful of them is inline watches: ReSharper C++ will display local variables, function parameters, current line expressions, and function return values right inside the editor. This feature provides immediate feedback during debugging sessions, which means that often you don’t even have to consult the Watches or Autos tool windows.
ReSharper C++ is careful to evaluate only those expressions that do not have side effects. At the moment, expression evaluation is limited to references, constants, member access, and built-in subscript operators. Subscript operators of std::vector and std::array are also evaluated as an exception. Please note that inline watches use the Visual Studio debugger engine to evaluate expression, which means that Natvis files with user-provided visualization rules are automatically supported.

ReSharper C++ also comes with its own debugger DataTips, which provide several advantages over their Visual Studio counterparts:

You can quickly search for a string inside a DataTip (just start typing with the DataTip open).

You can mark members of a class which will be used to construct a custom presentation string for objects of this class. To do this, invoke Highlight Property from the context menu on class members that you are interested in.

To access ReSharper DataTips, just click the inline value display. If you find ReSharper DataTips helpful, you can replace Visual Studio DataTips with ReSharper’s by enabling Override VS DataTips with ReSharper DataTips on the Tools | Debugger ReSharper options page.

Working with multiple breakpoints should now become easier. The new Go to Breakpoint action (Ctrl+Alt+F9) displays breakpoints in a context menu so that you can quickly navigate between them. In addition, the dedicated R# Breakpoints tool window (ReSharper | Windows | Breakpoints) groups breakpoints and displays the line of code where each breakpoint was set.

Breakpoints and tracepoints can also be created directly in the Find Results tool window, from the occurrence context menu.

But that’s not all — we are working on adding new debugger-related features. In particular, ReSharper C++ 2018.1 will bring debug step filters, a feature which lets you make the debugger step over certain functions (e.g. subscript operators or trivial getters). If you are interested in trying it, head over to the Early Access Program page when the EAP starts and install the latest available ReSharper 2018.1 build.

Language understanding

For the 2017.3 release, we specially focused on improving the product’s understanding of C++. We made sure the following new C++17 and C++14 features received support:

C++17 structured binding declarations allow declaring multiple variables that bind to subobjects of another object. This is particularly useful when working with functions that need to return multiple values. As with other identifiers, you can determine the actual types of structured bindings via ReSharper C++’s tooltips or the Quick Documentation popup.
Structured binding declarations support binding to array elements, public class data members, and tuple-like objects. Making your own classes support the tuple-like binding protocol requires specializing std::tuple_size and std::tuple_element, and if something goes wrong, ReSharper C++ will provide you with detailed error messages.

Return type can now be deduced for C++14 auto functions without trailing return types.
Supporting this language feature was rather complicated because, to determine the return type of a function declared in a header file, its body is needed. On the upside, implementing it also allowed us to fully support C++17 constexpr if statements, which can cause a function to have different return types depending on which constexpr if branch is chosen.

Type checking and return type deduction now work for lambda expressions, including support for C++14 generic lambdas.

Previously only functions could be declared as inline, but in C++17 variables can be declared inline too. This is now supported by ReSharper C++, and a warning will be issued when the inline specifier is required to avoid linking errors.

All in all, this brings ReSharper C++ almost to the level of standard C++ support provided by the Visual C++ compiler at the moment, with two notable features still in our queue to implement — fold expressions and evaluation of constexpr functions.

Improved support of explicit template instantiations. In particular, explicit instantiations of both class and function templates are now handled correctly by the Rename refactoring, and can be navigated to via gutter icons.

Code inspections and context actions

ReSharper C++ 2017.3 extends its set of available code inspections:

Binary operators with suspiciously looking identical or equal operands will be highlighted.

Default arguments on virtual functions are considered bad style (see e.g. Google’s C++ style guide for details). ReSharper C++ now includes an inspection which finds redefinitions of a default argument from a base function.

const and volatile specifiers on parameters in a function declaration have no effect and will be shown as dead code.

Function parameters that are not mentioned in the function documentation comment will be underlined, with a fix to insert the corresponding documentation line.

Member initializers in constructors that duplicate the corresponding default member initializers will be marked as redundant.

All user-defined literal suffixes must start with the underscore character according to the C++ standard. ReSharper C++ will warn you about literal operators that violate this requirement.

A couple of context actions were also added:

An action to move a member initializer from a constructor member initializer list to a default member initializer.

An action to switch between class and typename keywords in type template parameter declarations.

Code formatting

If you wish to preserve custom formatting just inside a block of code, ReSharper C++’s formatter can now be selectively disabled by wrapping this block with a pair of comments containing formatter directives: // @formatter:off to disable formatting, and // @formatter:on to enable it back.
Instead of disabling the formatter completely, you can configure it using inline EditorConfig-style settings and override only one or several of them, keeping common code style settings active. Please refer to the EditorConfig Properties help page for the list of supported properties.

Another long-requested formatter feature is the ability to align specific code elements in columns, which is now supported for assignment statements, declaration names, and single-line comments (configured by a family of settings in Indentation and Alignment | Align Similar Code In Columns).

There’s also a related multiline alignment setting, which controls the outdenting of command and member access operators in chained method calls.

The layout of linkage specification blocks can now be customized via two formatting settings, Indentation | Indent linkage specification block members and Braces Layout | Linkage specifications. The usual idiom of using extern "C" blocks in header files to create an API compatible with C is now supported:

Finally, two new settings, Spaces | Before/after commas in uniform initialization braces and Spaces | Before end of line comment, provide more options to match spacing in your code.

Navigation improvements

The Go to Declaration command is now available on dependent names inside definitions of templates. This should make it much more useful in template-heavy code. Since ReSharper C++ has no way of finding the exact entity that the name refers to, instead it will look through all the symbols and offer those with matching names and signatures as potential navigation targets.

In addition, Go to Declaration now lets you navigate from a member function definition to a declaration with a non-matching signature if no matching declaration is found. This ability comes in handy when you change the definition and need to update the declaration (even though we encourage you to use the Change Signature refactoring and related fixes for this purpose).

To-do patterns get a URL field, which creates a link in your code for navigating to external resources by Ctrl+Click on the to-do item, or via the Alt+Enter shortcut. This helps you keep your to-do comments brief and straightforward: no full URLs are needed, only an issue ID. Links in to-do items support the Peek Preview feature to display the linked issue inline in the editor. Also, you can easily locate the to-do item in To-do Explorer via the Alt+Enter menu.

Smaller navigation-related changes include:

Search Everywhere always shows text matches in a dedicated section, even when there are other results. So, you do not need to switch to Go to Text when you want to take a peek at text occurrences.

When occurrences are shown in the Find Usages window, ReSharper C++ considers and presents the context (e.g. function calls or return statements) from the surrounding lines.

The redesigned preview pane in ReSharper tool windows (shown above) and formatter options pages are now based on the Visual Studio editor. This gives preview pane code a more natural look: keywords and strings are highlighted, identifier colors are applied, and font settings and scaling are inherited from Visual Studio’s text editor settings.

Other changes

Catch2, the latest version of the popular Catch unit testing framework, is now supported. Its codebase has been updated to use C++11, with strong focus on both compile and runtime performance. If you are interested in learning more about new Catch2 features and Catch in general, a good place to start would be the announcement blog post and the Modern C++ testing with Catch2 talk by Phil Nash, the author of Catch.

The Performance Guide page in ReSharper options collects a set of Visual Studio and ReSharper settings that might affect overall performance in one place and provides a way to quickly change them.
While it does not have any C++-related tips yet, it can still help you improve the general responsiveness of your development environment.

Generative completion now allows creating definitions not only for member functions, but also for free functions.

Built-in live templates cctor and mctor which expand to a copy and move constructor, accordingly, were added.

]]>https://blog.jetbrains.com/rscpp/whats-new-resharper-c-2017-3/feed/1What’s New in ReSharper C++ 2017.2https://blog.jetbrains.com/rscpp/whats-new-resharper-c-2017-2/
https://blog.jetbrains.com/rscpp/whats-new-resharper-c-2017-2/#commentsWed, 20 Sep 2017 11:38:46 +0000http://blog.jetbrains.com/rscpp/?p=441Please welcome ReSharper C++ 2017.2! This is the second annual ReSharper C++ release, packed as usual with new features and bug-fixes. Take a look at the What’s New page for a quick overview, or continue reading for a deep dive … Continue reading →

Unfortunately, structured binding declarations from C++17 are not yet supported, but they are top-of-the-list for our next release.

On a related note, another important change in the 15.3 toolset is partial support for two-phase name lookup. It has to be manually enabled through the /permissive- conformance switch, but MSVC’s team plan is to turn conformance mode on by default in the next major compiler revision. If you want to move your code forward and make it fully two-phase clean, ReSharper C++ can be a great aid since it has been using two-phase name lookup since the beginning. You just need to pay attention to warnings inside template code—for example, ReSharper C++ will point out lookup errors during the first phase of lookup:
For help with errors related to two-phase name lookup, we have suggestions about missing template and typename keywords in dependent code:

There is some news about C support as well. ReSharper C++ now implements anonymous structures, a Microsoft C extension that allows declaring a structure variable within another structure without giving it a name. Members of anonymous structures can be accessed as if they were members in the containing structure. This extension is limited to C only, but it is supported both by Clang and GCC with the -fms-extensions option.

If you need to override a few functions from a base class, there is now an alternative to using the Generate overriding members dialog. Virtual functions that can be overridden will be included into the completion list when you complete inside a class body. When selected, these completion items will insert a full function declaration. To continue, you can use Generate implementation or Generate inline implementation – either context action will create a function body.

Finally, the Generate constructor dialog got a new option, Make empty constructors = default. As the name suggests, with this option enabled ReSharper C++ will = default the generated constructor when it is empty, so it’s a quick way to add a defaulted constructor if you need one in your class.

Code inspections and quick-fixes

ReSharper C++ 2017.2 adds several new code inspections:

The much-requested Inconsistent Naming inspection detects violations of naming style in your code, and the accompanying fix allows you to quickly invoke the Rename refactoring with the name changed according to the corresponding naming rule. By default, the naming inspection has the Hint severity, which means that naming inconsistencies do not appear on the marker bar and are not highlighted with curly underlines. If you want to enforce naming rules and find that this inspection is useful, do change its severity to Suggestion or Warning.
Naming rules used by the inspection can be configured on the Code Editing | C++ | Naming Style options page. This page has been reworked since the previous release and now allows adding new names rules and editing existing ones. The rules are checked in reverse order, meaning that a rule that comes later in the list has higher priority than the one before it.
For each naming rule, it is possible to specify the kinds (e.g. class, function or variable), accessibility, and specifiers (static, const, constexpr or volatile) of entities to which the rule should apply.Please note that the naming rules for getters and setters, which are present in previous versions of ReSharper C++, are now gone. You can use new options in the Generate getters and setters dialog instead to control whether or not to add is/get/set prefixes to getter and setter names.

One of the unique ReSharper C++ inspections is Member function may be const, which highlights functions that do not change member variables of the containing class and thus can be marked as const. ReSharper C++ 2017.2 adds a couple of related inspections, Local variable may be const and Parameter may be const (since 2017.2.1), which perform a similar analysis and show local variables and function parameters that can be made immutable.
If you consider using const everywhere possible as too excessive, reduce the severity of one or both of these inspections.

Unused entity inspections used to work only with local variables and function parameters. Their scope has been extended now to also include global variables, classes, enums, and enumerators that have internal linkage or are members of an anonymous namespace.

A number of new quick-fixes for existing inspections were also introduced:

Add #pragma once is the recommended fix when an include guard is missing in a header file. There are teams though that prefer using #ifndef/#define/#endif include guards, and ReSharper C++ now has a fix that wraps the header file with this combination of directives.

If there is an unused expression without any side effects inside a function of a type compatible with the function’s return type, ReSharper C++ lets you convert it into a return statement via the Return unused expression fix.

Trying to bind lvalue expressions to rvalue references is a compiler error, but sometimes it just means that a call to std::move was intended but is missing. To quickly add it, use the new Add std::move fix.

ClangFormat support and line wrapping

ReSharper C++ 2017.1 brought support for EditorConfig, a popular standard for defining code formatting preferences. In the C++ community, however, ClangFormat is the de facto standard for formatting tooling. ReSharper C++ 2017.2 adds support for reading ClangFormat configuration files, so if there is one in your project, ReSharper’s code formatting engine will automatically pick it up and use it. To find the configuration files that affect a particular file, ReSharper C++ looks for .clang-format and _clang-format files in the containing folders. ReSharper C++ will also help you understand exactly which style options are applied and where they come from:

You will see a yellow warning on ReSharper C++ formatting options pages if at least one preference on a page is overridden by ClangFormat options. Each overridden preference will be also highlighted with yellow:

You can see and study all ClangFormat configuration files that affect the current file in the File Formatting Info window:

Please refer to the Using Clang-Format help page for the full list of supported ClangFormat style options.

Another big change related to code formatting is support for line wrapping. You can find the option to turn it on or off, as well as a collection of options that control wrapping inside different syntax elements, in the Line wrapping group on the Code Editing | C++ | Formatting Style | Line breaks and Wrapping options page.

A number of new formatting options were added, in particular options that control:

line breaks after template headers and function return types;

indentation of parentheses and their contents in function declarations, function calls, and if/while/for statements; and

spaces around colons in range-based for loops and in lists of base classes.

Navigation features

Go to declaration now works inside the bodies of macro definitions. Of course, due to the textual nature of preprocessor macros, the results of such a context search are tentative. For macro parameters, the search will jump to the parameter declaration. For other identifiers inside macro bodies, all symbols inside the solution with names that match the identifier will be shown.

Go to Everything(Ctrl+T), Go to File Member(Alt+\) and Go to Action (Alt+Enter) have been improved as follows:

The query syntax got extended in several ways. ReSharper will now match identifiers even if the word order inside your query is mixed up:
On the other hand, if you add quotes around a search query, ReSharper will only look for exact matches. If you need even more control, it is also possible to combine exact search with wildcard characters like * and ?.

To streamline the navigation experience, Go to Text is integrated into Search Everywhere, so you do not need to deliberately use Go to Text to get text matches in search results.

A laptop-friendly Shift+Enter shortcut can now be used in addition to Num + to open search results in a separate Find Results tool window, where you can explore and filter items more easily.

Navigate to file nearby is a completely new navigation feature, which displays project structure around the current file in a popup menu. The top-level menu shows the solution, the current project, containing folders, and files in the same folder. From there you can navigate deeper, open files, and create new files and folders. Navigate to file nearby is not bound to a key shortcut by default, but it can be invoked similar to other navigation actions from the Navigate To context menu (Alt+Backquote) or via ReSharper | Navigate | Go to File Nearby.

Performance improvements

ReSharper C++ 2017.1 introduced the option to not reindex includers when preprocessor directives in a header file get modified. In the 2017.2 release, another common situation which caused bulk reindexing is addressed using a similar mechanism. By default, ReSharper C++ will now not reindex files after the current build configuration of a project is changed. Please note that code inspections may execute slower after a configuration change the first time you open a file, since ReSharper C++ will need to reparse the included files. If you prefer the old behavior, you can revert via the option Code Editing | C++ | Performance | Reindex affected files after a project or a file property is changed.

The second performance-related change is added support for the new asynchronous Visual Studio API for reading project properties, available starting with Visual Studio 15.3. In the past, ReSharper C++ had to query project properties on the main thread, which could lead to UI stalls when you opened your solution or changed project configurations. These freezes should be gone now, with the additional benefit of lower memory usage for storing project properties. Moreover, the lightweight solution load Visual Studio feature is now supported, and ReSharper C++ should no longer force loading of all projects in the solution even when LSL is enabled. If you encounter ReSharper C++ issues when running Visual Studio 15.3, please try disabling the option Code Editing | C++ | Performance | Read project properties asynchronously in Visual Studio 15.3 and later and reopening the solution. If it does help, do let us know!

CppCon 2017

This year’s biggest C++ conference takes place in Bellevue, Washington, USA on September 24–29. JetBrains is proud to return as a bronze sponsor and will have an exhibition booth set up on the 27th and 28th. If you’re there, stop by the booth to have a chat with members of our CLion and ReSharper C++ teams, give them your feedback, and consider attending one or more of the talks delivered by JetBrainers:

New standards to the rescue: the view through an IDE’s glasses, by Anastasia Kazakova (CLion Product Marketing Manager) at 2 pm, September 25.

Tools from the C++ eco-system to save a leg, by Anastasia as well at 3:15 pm, September 26.

The Holy Grail—A Hash Array Mapped Trie for C++, by Phil Nash (JetBrains developer advocate and the author of the famous Catch unit testing framework) at 9 am, September 29.

We are looking forward to seeing you there!

That’s it! Start your free 30-day evaluation and try out all the new features and fixes. As always, please leave us any feedback and report issues either in the issue tracker or on the support forum.

]]>https://blog.jetbrains.com/rscpp/whats-new-resharper-c-2017-2/feed/1C++ Annotated: Apr – Aug 2017https://blog.jetbrains.com/rscpp/cpp-annotated-apr-aug-2017/
https://blog.jetbrains.com/rscpp/cpp-annotated-apr-aug-2017/#respondTue, 29 Aug 2017 10:26:53 +0000http://blog.jetbrains.com/rscpp/?p=436Today we are happy to share our next compilation of C++ news with you. Subscribe to the regular C++ Annotated and be the first to get the next edition! C++ Annotated: April – August 2017 A long time has passed … Continue reading →

]]>Today we are happy to share our next compilation of C++ news with you.

Subscribe to the regular C++ Annotated and be the first to get the next edition!

C++ Annotated: April – August 2017

A long time has passed since the last edition of C++ Annotated. Which means today we have lots of great articles and news to share with you. In this edition:

C++ language news

C++20

Metaclasses

Conferences

Recent events like ACCU and C++Now

Upcoming events

Learning

Releases

C++ language news

C++20

With C++17 ready for final publication by the end of 2017, we can now start thinking about the future of C++ and in particular C++20. The Toronto C++ committee meeting was solely about just this! Just look:

Concept TS was merged into C++20 draft. It takes now only one clean syntax (out of three) and doesn’t include function concepts.

Metaclasses

The trickiest thing about ACCU 2017 was keeping secret Herb Sutter’s keynotes on metaclasses. This was the closing talk of the conference, but it made the whole audience of the big room at the Marriott hotel stay until very late. Now, that the proposal is live and the ACCU’s talk is finally published, everyone can learn more about this exciting topic.

What can make the C++ language more powerful and simpler? Can we avoid boilerplate code? Can we talk to a C++ compiler in C++? Can we get DSLs out of C++ without vendor-specific compilers? The answer to all these questions is ‘Yes’ if we use metaclasses.

More specifically, the idea is to enable you to describe some abstractions to the compiler and get metaclasses definitions that can be later used in the code. Today struct and class are the two main ways to define a type in C++, but with metaclasses, we can access way more!

Conferences

ACCU 2017

This year’s ACCU conference was huge and not only because of the Herb Sutter’s keynotes (though now it could be a tricky task to organize something more exciting). A couple of talks worth mentioning are: Odin Holmes’ “Modern C++ Design reloaded” (again about moving in the direction of meta-programming), “Mongrel Monads, Dirty, Dirty, Dirty” by Niall Douglas (showing how errors in C++ could be handled and providing a nice comparison of the options in terms of performance), “Grill the C++ committee” session (from a C++17/20 discussion to advice on starting a C++ proposal), and many others.

The playlists with all the videos are available and organized by the days on ACCU’s YouTube account. There are also a couple of trip reports worth reading, including one from JetBrains, where we share our booth experience and general impressions and thoughts on the conference.

C++Now 2017

If you were ever interested in cutting-edge C++ and wanted to work on new language features with a group of people with a similar deep interest in the language itself, C++Now is the proper place. A week spent in Aspen, Co, USA will fill you with dozens of bright and outstanding ideas, that will become your everyday C++ routine tomorrow.

This year’s event was no exception. While the unique feature of C++Now is a drive for discussions and collaboration that leads to hours of hot debate on-site, you can still get lots of useful information from the recordings. The playlist is already available.

And if you need recommendations on how to start over, I’d suggest you look at Tony Van Eerd’s “Postmodern C++” (awarded “Most Inspiring” and “Most Engaging”), Ben Deane & Jason Turner “constexpr ALL the things!” (awarded “Best Presentation”), all three parts of Alisdair Meredith talk about std2 (1st, 2nd, 3rd) discussing the future of the standard library in the world of modules-based approach and concept usages, and a very practical talk about Modern CMake by Daniel Pfeifer.

Upcoming conferences

The upcoming months are going to be pretty packed with lots of great C++ events. It will all start with CppCon 2017 in September followed by Meeting C++ 2017 later in November. These two events introduce Bjarne Stroustrup, Herb Sutter, Lars Knoll, Matt Godbolt, Sean Parent, and Kate Gregory as keynotes speakers, as well as dozens of other great speakers.
The Audio Developer Conference (former JUCE) will run in London in November, and will gather audio developers from all over the world to discuss the problems in the audio processing field, the specific libraries and solutions, as well as news around C++ language.

Learning

Past, Present and Future of C++

In May, Bjarne Stroustrup joined CppCast for the anniversary 100th episode of the podcast. He talked about his expectations for C++20 (in a nutshell, Concepts, Modules, Contracts, Networking, and likely no Reflection), as well as issues with compile times, code cleanliness and possible improvements, he also touched on the current state of the C++ committee and more.
Addressing a “time machine question” about what Bjarne would change in C++ if he could go back in time, he talked about good interfaces and the possibility of getting Concepts. Check the episode for more interesting thoughts from the C++ language creator.

With each modern standard, the language changes the way we think and solve problems in C++.

C++ is a language for safety critical systems, where the cost of error is high. But some existing guidelines are based on very old standards, and thus are outdated.

Saying this, Rainer hopes that C++ Core Guidelines will help to solve current issues. So he dedicates a series of posts to discussing the currently existing rules (350 in total) in detail, creating fables from each group and tieing them all together (posts are grouped in sections following the Guidelines structure). For example, learn about recommended practices to write Function Definitions, general rules for Classes, and many others.

Reading list

The C++ language is tough and complicated and developers often ask about recommended books on C++ good practices. All these books are well-known, but it’s always convenient to have them all in one list. So here it is, prepared by Jonathan Boccara in his blog. One may find there lots of modern language classics like Scott Meyers series, Herb Sutter’s (More) Exceptional C++, and Modern C++ Design from Andrei Alexandrescu, there are recommended books on Boost, template metaprogramming, and more.

Compare several compilers or several versions of one compiler (especially for the case, when you develop using one version and build on a target platform using another one).

Learn and experiment with the new language features.

You can also often share the code snippet online using such services.

Compiler Explorer (by Matt Godbolt) is one of the most famous online compilers. It’s often used during meetups and conference presentations, especially when talking about language features. It also shows the assembly produced by the compilers. But there are more names mentioned in the blog post, with their peculiarities highlighted.

Refactoring C++ code webinar

On August 17th we’ve run a live webinar with Arne Mertz as a speaker, the recording is now live. In an hour long talk, Arne covered general strategies and effective refactoring processes, showing lots of samples. It all started with one application where all the code was placed in one file. Step by step, Arne was extracting functions, removing duplicates, demonstrating parallel change strategy, extracting domain logic into a separate class and playing with the duplicate & reduce technique. There is a sample project available on GitHub, so you can follow the whole process.

Conan C/C++ package manager webinar

If you have ever developed a large C/C++ project or were interested in reusing certain packages and libraries, you might wonder about package and dependency managers for C/C++, then Conan is what you are looking for! In July we did a live webinar with SW Engineers from the JFrog team, who are actively contributing to Conan. An hour talk covered topics such as: creating packages from your own sources, discussing Conan profiles (what are they and how they help), and a way to skip the local cache to depend on a locally edited package. As usual, the demo project is available to try all the tips on your own. Find the recording by the link.

Compile-time string concatenation

Can you concatenate two strings in compile-time in C++? Can you do that with C++11? The blog post by Andrzej Krzemieński started with a typical static initialization order fiasco sample:
Quite a common solution might be “introduce a function notation to read a constant value”, but there are several reasons why this is not ideal and can lead to slow-downs. And here the author comes to compile-time constants and the need for compile-time concatenation. The rest of the article is about building a solution, that becomes more complicated because of C++11 and its restrictions.

A bug in GCC

If you think GCC guarantees you the exception safety, then you should check this story about the related bug in GCC. It shows a simple case that uses aggregate initialization and leads to a problem. Namely, you can get a Member that was initialized but never destroyed. The author later made another blog post showing another case where the same error occurs and that is close to real-world C++ code. Check these samples at least to confirm you don’t get similar leaks in your programs.

When comparison function does it wrong

PVS-Studio is famous for checking lots of projects for potential errors and sharing the result of such checks in their blog. In this post Andrey Karpov collected possible issues with comparison function, to share real-program examples. Several error patterns are discussed:

The StarCraft II API

Blizzard welcomes everyone interested, to try and implement a bot using the StarCraft II API. The library appeared on GitHub, along with a couple of tutorials (on how to create various types of bots, run simulator, etc.) and a list of examples. The API is built around protobuf defined protocol, it uses CMake to generate project files and Doxygen to generate documentation. The library supports all three platforms (Linux, Mac, Windows).

Releases

CLion

The latest release of CLion (2017.2) brought integration with Clang-Tidy, which means first and foremost that users are able to see Clang-Tidy warnings and benefit from Clang-Tidy quick-fixes right inside the IDE, in just the same way it works for CLion’s own built-in inspections. And secondly it means users can add their own check to Clang-Tidy and get them instantly in the IDE.
In addition to that, some existing inspections and quick-fixes were updated, C++17 came to the New Project Wizard, other improvements to PCH support and disassembly view in debugger were introduced. Learn more by the link.

ReSharper C++

Another C++ tool from JetBrains, ReSharper C++, which is a Visual Studio extension for C++, also got an update. With version 2017.2 ReSharper C++ now supports ClangFormat configuration files as a source of information for the built-in formatter. The tool shows the progress with C++17 features (selection statements with initializer, using in attribute namespaces, and capturing *this by value), polishes support for some C++11 features (including the work around friend declarations and user-defined literals). In addition, this release improves the code navigation and adds several new code inspections.

Qt

Qt Creator 4.4 is nearly ready for its final release. This version brings inline annotations for warnings and errors from the Clang code model (just like in Xcode) and changes to Rename refactoring that is now capable of doing Rename Files when renaming a symbol. And built-in Clang code model helps now with the highlighting of the identifier at the cursor. Check the blog post for other changes.

]]>https://blog.jetbrains.com/rscpp/cpp-annotated-apr-aug-2017/feed/0What’s New in ReSharper C++ 2016.3 and 2017.1https://blog.jetbrains.com/rscpp/whats-new-in-resharper-c-2017-1/
https://blog.jetbrains.com/rscpp/whats-new-in-resharper-c-2017-1/#respondMon, 24 Apr 2017 16:07:51 +0000http://blog.jetbrains.com/rscpp/?p=340ReSharper Ultimate 2017.1 is out! It’s been some time since our last post about updates in ReSharper’s C++ support, so let’s take a look at what has kept the team busy. Major areas of improvements include: Visual Studio 2017 support … Continue reading →

]]>ReSharper Ultimate 2017.1 is out! It’s been some time since our last post about updates in ReSharper’s C++ support, so let’s take a look at what has kept the team busy.
Major areas of improvements include:

Most importantly, ReSharper C++ introduces initial support for the Open Folder functionality and CMake-based projects in Visual Studio 2017. The latter is particularly helpful since it eliminates the need to regenerate and reload the Visual Studio project when CMakeLists.txt is modified. However, there are a couple of related caveats:

In the Open Folder mode without a CppProperties.json configuration file present, ReSharper C++ will use include paths set via the INCLUDE environment variable. You can start Visual Studio from the developer command prompt to have INCLUDE automatically populated with paths to the standard library and Windows SDK.

Since there is no Debugging property page, additional configuration is required if you want to use ReSharper’s unit testing capabilities. You can specify how to run tests on the new page, Tools | Unit Testing | C++ Tests, in ReSharper options.

Please note that support for this kind of projects is still experimental — do let us know if you experience any problems!

We’ve also updated ReSharper C++ to handle several new types of projects — properties like predefined macros, include paths, and others should be correctly read from VisualGDB MSBuild, Linux Makefile, and CUDA projects. Moreover, when a compiler other than MSVC is used, ReSharper C++ predefines a number of macros for better compatibility with GCC and CLang compilers.

Language features

C++17 nested namespace definitions are now supported in ReSharper C++. Available since VS 2015 Update 3, this feature provides a concise way of defining nested namespaces. When ReSharper C++ detects that the latest language standard is being used, the Convert to nested namespace definition context action is available to change the old-style syntax into the new one:

Introduce/Inline typedef

A couple of new refactorings were implemented to complement the existing Substitute typedef context action. The Introduce typedef refactoring allows you to quickly create a typedef for the selected data type and replace this data type and all its occurrences with the newly created typedef. The Inline typedef refactoring does the opposite: it replaces an existing typedef with the actual data type.

Needless to say, these refactorings also support C++11 type aliases. If you want the Introduce typedef refactoring to insert a type alias instead of a typedef declaration, set this behavior on the options page Code Editing | C++ | Code style.

Unit testing

In addition to Google Test and Boost Test, ReSharper C++ 2016.3 delivered first class support for Catch, a cross-platform test framework for C++. Catch is popular because of its ease of use and expressive API, which allows you to divide test cases into sections (each of which is run in isolation) and structure them using BDD style. The framework is distributed as a single header file, with no external dependencies (beyond the C++03 standard library). You can always get the latest version of this header directly at this URL. For an introduction to Catch, please refer to the Catch tutorial, watch the CppCon presentation, or read the article in the CLion blog.

We are also happy to say that the author of Catch, Phil Nash, joined JetBrains as a developer advocate last fall. If you have any ideas on how to improve Catch integration into JetBrains products or have feature suggestions for Catch itself, do not hesitate to contact him!

Other updates in unit testing support include:

Boost Test runner has been updated to support Boost 1.62, 1.63 and 1.64. We have also fixed performance issues while working with a large number of dynamic tests and changed the runner to ignore output from the test program, so it does not affect parsing of the XML test report.

Google Test runner now supports the 1.8 release of the framework. ReSharper C++ will also correctly merge results of several runs and calculate total execution time if the --gtest_repeat flag is used to run the tests several times.

The list of unit tests is now automatically updated after external file changes (for example, when unit tests are generated as a result of a build step).

Completion

Postfix templates, a popular feature first introduced by ReSharper for C#, allow you to focus on your data rather than the syntax. ReSharper C++ gets a set of its own templates specifically tailored for C++. You can now quickly wrap an expression with several available templates, including if, else, while, do, return, switch, foreach, and others.

The new options page Code Editing | Postfix Templates lists all the available postfix templates. It allows you to disable the ones you do not use, and contains a number of related options.

One common C++ coding practice is to prefer non-member non-friend functions to member functions. This is a great way to increase encapsulation and keep class interfaces as minimal as possible (see item 32 in Scott Meyer’s “Effective C++” for a detailed discussion). However, from the tooling perspective there have always been drawbacks to this practice. Whereas member completion list shows all the available member functions, it’s not so easy to list and complete non-member functions which are applicable to an object of the given class. This problem is now solved by ReSharper C++: when you type a dot (.) or an arrow (->) after an expression, free functions that accept that expression as the first parameter will be suggested in the completion list as well as member functions.

Code cleanup and inspections

ReSharper C++ 2017.1 introduces cleanup tasks, including:

A set of tasks to apply the existing quick-fixes for common code issues.

The Update file header cleanup task, which updates the comment at the top of the file according to the template specified on the options page Code Editing | File Header Text (take a look at the related blog post for more details).

To run code cleanup, use the command ReSharper | Edit | Cleanup Code (Ctrl+E, C) — it will work either with the current text selection, the entire file opened in the text editor, or on a set of files and projects selected in the solution explorer. You have the choice to use the built-in profile (which has several of the tasks that you might not always want to run disabled) or create your own. Here’s one that shows all the available C++ cleanup tasks:

Control flow inspections (uninitialized/reassigned/unused variable and the like) used to work only with local variables and function parameters, but now class fields are also analyzed. For example, ReSharper C++ will find a self-initialization error in this snippet:
Or an uninitialized member here:

If you declare a local variable and initialize it later without any conditions, ReSharper C++ now suggests to join declaration and assignment where the variable is first initialized. This removes the unnecessary statement and improves code readability.

We have introduced several ReSharper-specific C++11 attributes that can be used to improve the results of certain inspections. For example, ReSharper C++ now understands the [[rscpp::format]] attribute (or, alternatively, [[gnu::format]]), which can be used to enable printf format string analyses for user-defined functions (RSCPP-15890).
There are also attributes to mark functions as having side effects (see RSCPP-18615) and guard classes for which the Unused variable highlighting should be suppressed (RSCPP-18764) — please refer to the corresponding issues for examples of their usage.

Private special member function is not implemented, which reminds you to use the C++11 = delete specifier instead of making the function private and omitting its definition to prohibit its usage.

ReSharper’s File Status Indicator (the small icon at the top of the Error Stripe) receives a new context menu. With a right-click on the icon, you can quickly toggle not only ReSharper code analysis, but also identifier highlightings and Visual Studio code analysis (the lightbulb and squiggles). If there are code issues in the current file, you’ll also see commands for navigating between issues of the highest severity level (you can still use the good old Inspect | Next/Previous Error/Warning commands to do that).

Finally, a new option on the options page Code Editing | C++ | Inspections controls the visibility of gutter icons (like “Navigate to definition/declaration”), should you find they clutter the user interface too much for your liking.

Documentation support

ReSharper C++ 2016.3 finally learned to display rich syntax-highlighted tooltips for C++ code elements. The contents of the tooltips mirror what was previously available through the Quick Documentation popup, namely function and variable types, containing namespace, template and function parameters, as well as documentation comments.

Finally, while only references to function parameters were resolved before from inside documentation comments, now template parameter references are also supported. This means that they will be shown in the list of results from Find Usages and updated by Rename when it is used on a template parameter.

Command line tools

ReSharper Command Line Tools (CLT) are a standalone set of command line tools that enable you to run code inspections outside of Visual Studio (for example, on your CI server or code quality management system). You can now use inspectcode.x86.exe from the CLT distribution to analyze C++ projects and generate a report with found code issues. What’s the best part? CLT are free and do not require an active license. To analyze your solution, just run inspectcode.x86.exe -o=report.xml YourSolution.sln.

You can either get CLT via a NuGet package or download a standalone archive. In the latter case ensure that the downloaded .zip file is “unblocked” before extracting: right click on the file, select Properties and click Unblock. (Failure to do this will cause the .NET framework to load the application in partial trust, which means it won’t load or run correctly.)

Performance

In terms of performance, we have recently targeted ReSharper C++’s memory usage to make it work better with huge solutions. (Since we still run in-process, we’re limited by the amount of memory Visual Studio can use as a 32-bit process.) As a result, both the memory footprint after indexing and memory traffic during indexing have improved significantly. In some cases (like the Unreal Engine 4 solution), the amount of managed memory used has decreased by up to 30%. Furthermore, a number of issues have been resolved that had caused excessive memory usage due to background editor and Find Results tabs. All of these changes should help with the debugging experience, since additional memory usage during debugging might have led to memory pressure. If you had problems with debugging before, we would also recommend trying Visual Studio 2017, which improves memory usage during debugging.

In C++ code, when you change preprocessor directives in a header file anything can happen. For example, if you add a #define or #include some file into a header file, the meaning of code can change in any file that uses that header. ReSharper C++ used to reindex all includers after a change like this, which is quite taxing on big projects, especially for common headers which get included into most C++ files. We have revisited this behavior, and now ReSharper C++ does not reindex these files by default, so the symbols in them are still used for navigation and refactoring purposes. This is a compromise between correctness and speed, the old behavior can be restored using an option in the Code Editing | C++ | Performance page. This page also contains a new option to limit the number of concurrent threads used by C++ caches — you can try tuning it to improve responsiveness during the code indexing phase, at the cost of total indexing time.

If ReSharper’s performance is still unsatisfactory, you can use the Third-party code options page to stop ReSharper C++ from indexing specific files and folders.
This page allows you to specify two kinds of filters:

Skipped Code contains files that do not get indexed at all, and is usually the right way to exclude third-party dependencies. Only indexing roots (normally .cpp files) are excluded, so if a .cpp file that is indexed includes some header files, their contents will be indexed regardless of third-party settings (since this is a prerequisite for correct parsing). So in practice, you should be able to just add the directories with third-party libraries to “Skipped code”, and if you include a header from a skipped library into your code, ReSharper will still be able to navigate to it.

Library Code contains files that ReSharper C++ must not modify. Highlightings are disabled inside these files, but they get indexed and ReSharper C++ is aware of symbols inside them. For example, Goto Symbol and auto-import will work for those files.

The File and folders list can only contain files and folders that are a part of the solution. The File masks list allows to match arbitrary paths. Masks are automatically prefixed by **/ and are matched against absolute file paths. If you want to match all files inside a folder, /** would also be required at the end of the mask. So for example, files inside C:/Foo/Bar would be matched by Bar/**, Foo/Bar/**, or C:/Foo/Bar/** (although shorter masks might match unwanted folders too).

Code formatting

EditorConfig offers a convenient way to share code style settings between teammates who use different editors and IDEs. ReSharper 2017.1 supports EditorConfig configuration files out of the box. To learn more about this, refer to the Using EditorConfig help section or watch the introductory video.

A new setting in the General Formatter Style options page (turned off by default) makes ReSharper C++ automatically detect and set the indent size used in a file. This feature becomes particularly handy in solutions where different files have variable indent sizes.

Indenting of preprocessor directives is now supported and controlled via the Indentation | Preprocessor directives indenting formatter option. Code that uses the OpenMP API is one example where this option is crucial for correct formatting:

The list of other formatter options introduced for improved configurability includes:

Indent namespace members.

Break line in simple case statement.

Spaces within/after parentheses in cast expressions.

Place enumerators on new line.

Align multiline chained method calls and binary operators.

Navigation and find usages

The list of small and not-so-small improvements in navigation and find usages includes:

The Find Results window now works asynchronously, meaning that you can work with the results tree while usage search is still in progress.

The Go to Everything and Go to Text popups support inline commands for advanced filtering of search results.

The Find Results window allows you to group results by kind of usage. This ability is very useful if you want to inspect only specific usage scenarios.

Recent Files can delete entries with the Delete key, and both the Recent Files and Recent Edits popups will now show the path of the file, to avoid confusion with similarly named files.

There is a new setting to remember the last search in Go to Everything, Go to Text and other search actions.

ReSharper’s Search & Navigation page adds a new option to open files in the preview tab from everywhere. This option is turned off by default.

ACCU 2017

The ACCU 2017 conference takes place in Bristol April 25-29 and as always has a great lineup of presenters and a lot of interesting talks, including “Functional C++ For Fun And Profit” and “A look at C++ through the glasses of a language tool” by our very own Phil Nash and Anastasia Kazakova. You can watch video recording on the ACCU conference YouTube channel later if you do not attend, but if you do, be sure to stop by the JetBrains booth to say “Hi,” grab a couple of souvenirs or shoot any questions at members of the ReSharper C++ and CLion teams.

That about wraps it up! All in all, 210+ issues have been fixed in the 2016.3 release iteration, and 140+ issues in 2017.1. We’d like to give a big shout-out to everybody who tried Early Access Preview (EAP) ReSharper builds and helped us iron out the bugs and improve the product. As always, please leave us any feedback and report issues either in the issue tracker or on the support forum. Develop with pleasure with ReSharper C++!

]]>https://blog.jetbrains.com/rscpp/whats-new-in-resharper-c-2017-1/feed/0C++ Annotated: Jan – Mar 2017https://blog.jetbrains.com/rscpp/cpp-annotated-jan-mar-2017/
https://blog.jetbrains.com/rscpp/cpp-annotated-jan-mar-2017/#respondTue, 18 Apr 2017 15:21:44 +0000http://blog.jetbrains.com/rscpp/?p=401Today we are happy to share our next compilation of C++ news with you. Subscribe to the regular C++ Annotated and be the first to get the next edition! C++ Annotated: January – March 2017 In this edition: C++ in … Continue reading →

C++ Annotated: January – March 2017

C++ in 2017

The C++ ecosystem

This blog post about the C++ ecosystem in 2017 is worth a special mention. Written in January, it overviews nicely the main expectations and trends, and not just about the language. While C++17 is indeed the main topic for this year’s discussions (as well as the features that failed to be included and so postponed for the future), it is also about adopting new standards and libraries, and of course the community including user groups and conferences.

C++17

As C++17 is approved, pending national body comments, there are lots of resources now where you can find the final feature list, explanatory code samples, committee meeting live threads and committee meeting trip reports. This list by Bartlomiej Filipek is quite useful as it provides code samples for each feature, lists the key compilers (GCC, Clang, MSVC) explaining the versions where the feature is supported, and links to various additional articles. It’s very detailed and includes every small change.

News

Toggles in functions

A tricky problem with bool-typed toggles in functions is covered by this blog post. What at first glance looks like a readability issue, can actually grow into a bug especially inside some overloaded methods. The post discusses several solutions, including one proposed by the blog author.

Clang-tidy: easy start

Clang-tidy is the topic of regular blog posts, lightnings and even big conferences talks, like the one recent at C++ Russia 2017. Indeed, it’s a quick and easy way to get an analysis of your code base and even apply some fixes instantly.

If you’d like to try Clang-tidy, this blog post is a good place to start. Sharing a basic example where code modernization is needed and some cases with missing override attributes, it goes through the setup instruction step by step and teaches you to run a single check, apply a fix, and analyze the whole project (taking into account all the compile flags, etc.).

Continuous integration with C and C++

The challenges of CI for C and C++ are covered in this Conan blog post. It starts by explaining the C and C++ building processes, showing how the build systems can help with the incremental build. Then it goes on to binary management questions and incremental build complexity with regards to CI. The benefits of Conan Package Manager in this area are also mentioned, including re-build logic, profound dependency management, a way to specify build order of dependencies, and so on.

Inserting elements into STL container

In his blog, Fluent C++, Jonathan Boccara discusses the problem with inserting several elements into an STL container efficiently. This provides an interesting overview of std::back_inserter and std::copy. The main idea is that knowing the size of the data to be inserted can help a lot in your optimization tasks.

Refactoring principles

Arne Mertz is well-known for his Simplify C++ blog and especially his series of posts about code refactorings. This time he writes about the basic refactoring principles – sounds philosophical, but they’re very useful in practice. What are these principles? In a nutshell, go with small steps that you can compile, test and commit; select a direction from the very beginning and follow it, postponing not-related changes; and don’t be afraid to break code styles, duplicate code and do other things that you usually try to avoid, if that is really necessary as an intermediate step in your refactoring procedure.

Readable modern C++

At the end of February, Timur Doumler joined C++ Russia 2017 and the Saint-Petersburg C++ user group meetup to talk about readable code and especially readable modern C++. The talk highlighted the general principles, like naming conventions, the necessity of comments, and eliminating code redundancies. Timur also put forth his ideas on how to make C++ more readable with the latest standards (from C++11 to C++17). The meetup version of the talk was recorded and is available on YouTube (with slides). He also delivered this talk at the C++ London meetup group.

Concepts

This is no rocket science but a simple example of when Concepts could be beneficial. The article starts from a very simple arithmetic code sample, eliminating the compilation issues one by one. But then, it adds Concepts and gets all of them at once. Sounds good, doesn’t it? Concepts are not coming to C++17 (they still require more work and polishing in details), but that doesn’t mean you can’t start thinking about where it makes sense to adopt them in your code base.

To Catch a CLion

Catch is a cross-platform test framework for C++. It is known for its easy setup – only a single header is required, and no external dependencies are needed. Not to mention easy-to-use test cases, which are designed as self-registering functions or methods and can be divided into sections.

While this framework is not as popular as Google Test or Boost Test, it’s seeing more and more interest from the community. Phil Nash, the author of Catch, is now working at JetBrains as a developer advocate and has already influenced integration into two (out of three) C++ tools by the vendor, ReSharper C++ and CLion. This article in the CLion blog shares some useful tricks around its integration into CLion and the use of the framework itself.

The future of the C++ job market

If you feel like discussing the C++ job market and its future, go ahead and join this thread on reddit, but first invest 5 minutes into reading this article from Bartlomiej Filipek. Why? It offers a nice summary of the areas where C++ is currently applicable and lists the language’s advantages. It also gives advice for newcomers and summarizes the results of a Twitter poll on whether the C++ job market is stable, decreasing or growing.

emBO++

In case you are interested in embedded development, you’ll be glad to learn about a new conference dedicated to it, entitled emBO++ and driven by Odin Holmes. This year the talks covered Standardese (so called next-generation Doxygen), clang tooling for embedded systems, profiling and many more topics. Listen first hand to Odin at CppCast, a developer who is really keen on microcontrollers. The discussion covers his general impression, an overview of the audience, and of course technical specifics around embedded development.

Compiler Explorer goes Patreon

Compiler Explorer is a great online tool for seeing what your C++ code compiles down to when various compilers are used. Matt Godbolt, the author and maintainer, has now opened a Patreon page for the project, primarily to cover the hosting costs. It has also given him momentum to accelerate ongoing development, at least for now, so do check it out.

Releases

CLion

CLion 2017.1 was released at the end of March with nearly full support for C++14 (now only constexpr left), nested namespaces from C++17, precompiled headers support, disassembly view in debugger in case of GDB, support for the Catch test framework. There is also experimental support for the Microsoft Visual C++ compiler, so if you are not a fan of MinGW (MinGW-w64) or Cygwin, that’s something good for you to try out in CLion.

The CLion team also announced the preliminary roadmap for 2017.2, coming later this year. The plan is to focus on bug fixing, performance improvement and polishing of the existing functionality. Check it out in CLion’s blog.

ReSharper C++

ReSharper C++ 2017.1 brought support for Visual Studio 2017 and CMake projects, extended the list of supported postfix templates, and added some new options in formatting. It also came with lots of enhancements for inspections and code cleanup tasks. For more details see the ReSharper C++ site.

Visual Studio

Talking about Visual Studio 2017, we should mention improvements in its code analysis, including C++ Code Guidelines checkers. Example include marking objects as const unless you are writing to them, marking objects as const if passed to a function that doesn’t modify them, and using constexpr for values that can be computed at compile time (and same for functions).

Besides, Visual Studio 2017 supports several C++ compilers to serve various needs and use cases: MSVC, Clang, and GCC.

Qt Creator

Qt Creator 4.3 Beta was announced in late March. In terms of CMake support it now comes with CMake server, which is an alternative way to get project information (instead of parsing the generators output). It also supports different contexts for file parsing and experimental Clang-based rename refactoring.

]]>https://blog.jetbrains.com/rscpp/cpp-annotated-jan-mar-2017/feed/0C++ annotated: Sep – Dec 2016https://blog.jetbrains.com/rscpp/cpp-annotated-sep-dec-2016/
https://blog.jetbrains.com/rscpp/cpp-annotated-sep-dec-2016/#respondThu, 19 Jan 2017 11:53:14 +0000http://blog.jetbrains.com/rscpp/?p=338Today we are happy to share our next compilation of C++ news with you. Subscribe to the regular C++ Annotated and be the first to get the next edition! C++ Annotated: September – December 2016 In this edition: Survey Conferences … Continue reading →

C++ Annotated: September – December 2016

Survey

Conferences

These months were full of great conferences – CppCon, ADC (former JUCE), LLVM US Meetup, Meeting C++, and some more local group meetups and smaller conferences. They are over now, but playlists with talk recordings are available for those who missed an event or just want to dive into it once again.

CppCon

First came CppCon 2016. The biggest event in the C++ world brought us 7,653 minutes of video recorded this year for 111 presentations and 31 lightning talks: from philosophical keynotes by Bjarne Stroustrup titled The Evolution of C++ Past, Present and Future to the state of C++ Core Guidelines in Neil MacIntosh’s The Guideline Support Library: One Year Later and many more. Also, don’t miss great advice from Jon Kalb: “Don’t use unsigned for quantities” from his lightning talk, unsigned: A Guideline for Better Code.

ADC

ADC (former JUCE) conference gathered Audio Developers from all over the world, and brought to light lots of topics around C++ modern language features, performance optimization and embedded development. Keynotes varied from the fantastic Dan Saks speaking about modern C++ instead of pure C in embedded development, to the legendary Roger Linn with his LinnStrument on stage playing demos.

LLVM US Meetup

The yearly LLVM US Developers meetup took place in early November in California. Among the recordings from the event one can find a highly interesting talk by Gor Nishanov about LLVM Coroutines, the story of LLVM and Clang transition to CMake by Chris Bieneman, and many more. The JetBrains C++ team also joined the event with a small lightning talk by Ilya Biryukov on how the compiler frontend is different from what an IDE needs, trying to explain why our C++ tools do not rely on Clang as a code parser.

Meeting C++

Meeting C++, the key European C++ event, was as usual held at the Andels hotel in Berlin this past November. The organizers brought together many famous names from the C++ community, including Bjarne Stroustrup, James McNellis, Timur Doumler, Jon Kalb, Michael Caisse, Arne Mertz, Odin Holmes, and many others, and offered an impressive program. Besides, it’s worth mentioning a quiz from Diego Rodriguez-Losada, the author of Conan. Interested in challenging yourself? Check 10 tricky code snippets from Meeting C++ in the Conan blog.

User Groups

The extensive worldwide collection of C++ focused user groups continues to grow, with at least two new groups starting up this quarter.

In Russia, the St. Petersburg C++ User Group started in October and has been meeting monthly since. Meanwhile, in the UK, C++::London started in December and also plans to continue monthly, with the January meet-up already scheduled. Both groups have been well attended, so if you’re in or near either of those cities do join up.

Both Meeting C++ and ISOCpp maintain up-to-date lists of C++ meetup groups worldwide, so consult those pages to find something near you.

News

Catching bugs at compile time

Andrzej’s C++ blog introduced a couple of blog posts on catching this non-obvious bug at compile time. The sample is simple and was generated by selecting an inappropriate completion suggestion. Still the discussion is interesting as an overview of possible workarounds in order to catch such issues with the help of the compiler. The author tried invoking a memory access violation (by providing another String implementation that assumes it will never be given a Null pointer), then comes to __builtin_unreachable()– and preconditions-based implementation samples. Another solution discussed in the blog is const usages.

Understanding fold expressions

Reducing a parameter pack over a binary operator with the fold expression is a new ability provided by the upcoming C++17. In his blog, Sumant Tambe tries unary left fold for operators and shows some interesting observations from his test, which shows some differences in how Clang and GCC handle the feature. There is also a valuable discussion of corner cases (like empty or single parameter packs).

Modern C++ features with Arne Mertz

The Simplify C++ blog by Arne Mertz was as usual full of interesting posts on various topics. Two attract the most attention: first, a general introduction to user-defined literals, with samples and use case description, and string literals (C++14) case in the very end.
Second, a series about variadic templates, providing full instruction on how to build and expand the parameter pack in templates. Empty packs, sizeof… operator and some additional tricks were also discussed.

42.times do

If you want to write something similar to “42.times do …” in C++, the answer by Dmitry Ledentsov is user-defined literals. Jon Kalb, however, attempted to play with it with more traditional syntax, so if you are not afraid of SFINAE, variadic templates, perfect forwarding, etc., check his blog post. The core idea among others is to make the code general, working for functions, function pointers, function objects and lambdas, with arbitrary values to be used as parameters to the callable.

Error handling strategy

Jonathan Müller in his foonathan::blog() published of series of posts on error handling. He discusses user errors, system errors and programming errors, checking whether it’s worth using recoverable or unrecoverable error handling strategy in each of the cases. The series also includes tips on customizable and modular assert implementations, as well as a discussion of C++ type system flexibility.

Next generation Doxygen for C++

Doxygen is a well-known format (de facto standard in many cases) for generating documentation from the annotated sources in various programming languages, including C++. Standardese (by Jonathan Müller) is a new library and a tool for getting documentation for C++ code. Its main goal is to fit C++ code bases more accurately, formatting the docs in a similar way to the standards themselves. It also aims to handle C++ language features in a smarter way (like SFINAE), provide balanced type information (not overwhelmed with various aliases and unnecessary return types), document private members, and more.

The Internet of Things, embedded development, and the future of C++

Qt blog published a research article looking into potential IoT market growth. Some interesting trends are mentioned. The number of connected devices is estimated to reach 20.7 billion by 2020, and 95% of today’s embedded systems are created with C/C++. Given that the number of C++ developers is growing at a very modest pace, how do we produce the software for that many devices? One of the answers suggested by the article is to enable C++ developers to be more productive. What better area for tools to make a difference! Check the blog post for the details.

Phil Nash & C++ team in JetBrains

In September Phil Nash, a well-known speaker and an author of the Catch framework, signed up as a Developer Advocate for C++ tools at JetBrains (also covering Objective-C and Swift). In his interview he shares his story and provides his vision on his duties as a developer advocate. There is also another episode of CppCast with Phil, focusing on his role in the community, Catch 2 and recent releases of JetBrains C++ tools.

Functional C++ for Fun and Profit

Phil Nash has a small tour with his “Functional C++ for Fun and Profit” in November and December, which includes many European User Groups meetups and the Meeting C++ conference. If you missed the discussion of the functional approach to software design and how it applies to modern C++, catch up with the recording.

Online compilers and not only

Jens Wellers overviewed the web resources that allow you to compile a piece of C++ code right in the browser and are collaborative in the sense that multiple people are able to edit the code interactively. It turned out to be a useful list, with not so many options supporting the latest C++ standard.

There is also a nice resource providing a long list of basic C++ code samples. Each code sample comes with a description and a comment section for discussion and questions.

CMake reference by LLVM

LLVM 3.9 dropped the autoconf build system in favor of CMake. To make the life of LLVM contributors a bit easier and clearer, the rich document on CMake was introduced. Not being a full tutorial or every feature reference, but more like a general introduction to the basic commands, principles and solutions used across the LLVM project, it can be helpful to both LLVM contributors and those who are starting to learn CMake.

CMake support in Visual Studio

Visual Studio 2017 will be delivered with two new options for those who are not using Visual Studio projects – open project from folder and CMake support. If you are planning to start/open a CMake project in VS, check their blog post, in which Marian Luparu gives a quick overview of the CMake features in Visual Studio. It includes opening CMake-based projects and working with them to benefit from all the intelligent features VS provides as an IDE. It also provides an ability to edit CMake files, update CMake Cache and tune CMake configurations. And of course, users can build and debug such solutions in Visual Studio 2017.

Shuffling data

Understanding the performance and drawbacks of standard functions is essential in order to use them effectively. Daniel Lemire in his blog post runs a comparison of the standard function for date shuffling (std::shuffle) and the standard Fisher-Yates shuffle algorithm. Check the blog post to see who won!

Is code faster than data?

Another performance test was run to check whether custom code for compile time data structure lookup functionality was faster than data. To be exact, the author compared the performance of the switch statement to that of a simple array type. The test was compiled within Visual Studio 2015 for 6 various data containers, running sequential, shuffle and sparse sums. The switch function turned out to be much, much slower than other options! Read the blog post for an explanation of the results.

Can a C++ package manager be written in C++?

Conan blog starts a discussion, sharing arguments for Python (for both UI language for packages definition and package manager core), and some philosophical fallacy around C++ package manager written in C++. Do you agree? Or do you think it’s more practical to use the same language (i.e. C++) than a completely new Python toolset?

Releases

CLion 2016.3

CLion 2016.3, another major update of JetBrains’ cross-platform IDE for C and C++ development, brought lots of key improvements. User-defined literals are supported including Rename refactoring, C++14 digit separator support, C11 keywords completion, and overload resolution improvements. Code analysis fixes from the language side include: ability to change CMake generation directory, ability to build only those CMake configurations that were added in settings, ability to open project from existing directory, and more. From the project model side code analysis fixes include project templates, remote debug on Windows, semantic highlighting, and more.

ReSharper C++ 2016.3

The ReSharper family received an update too, including ReSharper C++ 2016.3. With new refactorings (Introduce/Inline Typedef) to clean-up code, postfix completion to speed up code typing, Catch test framework support and dozens of smaller improvements, this Visual Studio extension is even more powerful and user-friendly.

Qt Creator 4.2

Qt Creator 4.2 was released with improved CMake support, cleaned projects mode UI, an ability to get local diff, an option to exclude files from indexing, and Clang code models enhancements.

PVS-Studio for Linux

PVS-Studio analyzer was released for Linux. To prove it was worth the effort, they put the most famous projects under investigation and re-checked the Linux kernel. This helped catch issues with string operations having the wrong string length, incorrect order of arguments, precedence problems, and others.

A: Hi Phil, and welcome to the JetBrains team! Let’s talk about you. Can you please share a bit about yourself?

P: Hi Anastasia. Thanks for having me here. A bit about me? Well, I’ve been programming since I was 9. Like most who came of programming age in the early 80s, I started with various versions of BASIC on 8-bit home computers (ZX-81, ZX-Spectrum, Commodore-64, BBC Micro and others), but within a few years progressed on to assembler (mostly 6502 – but later 68000 on the Amiga, then 8086 on PC). In the early 90s I went for my first programming job, writing C & C++, which I prepared for by reading a book on C the night before. Somehow I managed to bluff my way in – but I hadn’t been there long before I realized I knew more C++ than anyone still there. That was the start of my C++ journey. It started on MS-DOS, but as the 90s progressed I naturally fell into Windows – which I did exclusively for the rest of the 90s.

A: What’s your background as a developer? I know you did C++ on Windows for a very long time. How did you end up doing iOS development in Objective-C and now Swift?

P: In the 2000s I changed things up a bit. The signs were there that C++’s heyday was coming to an end and I thought I should either learn other languages, or see which industries C++ would remain strong in. I started with the latter and moved into embedded programming – specifically mobile comms – where I stayed for about five years. It was a good experience and I’m glad I did it, but I also learned that embedded-programming was not for me. So I branched into banking, where I’ve mostly stayed until now. During that time, though, I also moved on the “other languages” front. First C#, then Python, then D and F#. At home I’d switched over exclusively to Macs, so I was interested in learning Objective-C, but it wasn’t until the iPhone AppStore launched that I gathered sufficient motivation to get past the initially steep learning curve!

I took three weeks off work to learn Objective-C and the iPhone SDKs (it wasn’t called iOS yet) and wrote my first app – a turn-based strategy game based on the classic board game, Risk.

It was initially quite successful – at least for a spare-time project – enough that I kept going with it. If I’d kept up that momentum, who knows where it would be today. Unfortunately I was still working at a bank and that was when the credit crisis hit! 80-hour weeks suddenly became the expected norm and I had to take on extra responsibilities – so there was no time, nor space in my brain, for outside work.

By the time I was able to pick it up again it had really got left behind. It was also hard to maintain and extend, due to being my first iPhone app – and first Objective-C codebase. I was learning as I went and it showed! So I started adding tests and doing significant refactoring. By this time I also started giving talks on Objective-C – hoping to help others past that initial learning curve too – it gets much easier on the other side.

A: Let’s talk about C++. The language has been here for many years. Do you think it will stay for long? Are the new standards valuable enough to help it compete with other modern programming languages?

P: When I first started worrying about the decline of C++’s dominance, the “modern languages” that were taking over were Java and C# – and I’ve since worked with both – especially C#. When the next standard kept delaying, that decline seemed to accelerate. At the time I thought there must be another systems language ready to take over. That’s when I got interested in D – which started as a reboot of C++ – dropping C-language compatibility (but retaining binary compatibility). D2.0 was being worked on by Andrei Alexandrescu – a well known name in C++ circles – and looked very promising indeed. But D didn’t get the traction that I thought it deserved. In the meantime C++11 finally arrived and the community re-energized around it. It actually started looking somewhat modern again (even beating Java to gaining lambdas)! That in itself was enough to kickstart the so-called “C++ renaissance”. But what really did it, I think, was the switch to the “Train Model” for future standards: a new standard every three years, containing whatever is ready at the time – along with the idea of separate TSs (Technical Specifications) – allowing those features not ready for standardization to still be implemented consistently, if experimentally, by compilers. C++14 really cleaned up the language in the wake of C++11 – and C++ is continuing that progress. We’re already looking ahead to C++20 and beyond.

Along with a huge surge in committee membership and participation, it seems all the blocks that led to the C++0x impasse have been removed and the community is more alive than it has ever been. So, while C++ may never again reach the overall dominance it enjoyed in the 90s, I believe it will remain a popular, widely used language for a long time to come.

That said it will always be hampered by its legacy back to the 70s – via C – which itself was rooted in the constraints of the 60s. Some isolated features have been deprecated or completely removed, but in general C++ can fundamentally only grow larger and more complex. And now we have some very interesting new systems languages gaining traction – notably Rust, Go and Swift. C++ is going to have to share the limelight, even in its own wheelhouse.

A: What’s your opinion about the upcoming C++17? Looks like some people in the community are disappointed with how it’s going.

P: I count myself among those who were disappointed when news first broke of what would not be in C++17. Let’s face it, we were all expecting to see Concepts (finally) make it in. And Modules. I think Modules have the potential to transform the way we use C++ – and solve two of the biggest problems with the language today (build times and fragile dependencies). We were hopeful of other features too, such as coroutines. But when the news dropped I think many of us were wondering if anything actually made it in!

But on reflection there do seem to be a lot of nice features coming. I think a lot of us were taken by surprise that structured bindings, a form of specialized pattern matching, made it in at the last minute, for example. string_view, variant and uncaught_exceptions are going to make a big difference as well. None of these are headline features, but they all contribute to cleaner, more efficient, code-bases in ways that C++ still sorely needs. And, at the end of the day, I see this is a victory for the Train Model. If we were still using the C++11 approach we wouldn’t be getting a new standard at all in 2017. Maybe we wouldn’t have even had C++14. Yet here we are, now, enjoying C++14 and looking forward to to C++17 very soon. And C++20 is closer than it sounds! Plus the TSs mean we can actually start playing with features like Modules and Coroutines already in most compilers.

A: Swift for the Curious – I was surprised when I saw this topic from you at ACCU 2016. Could you please share with our readers your opinion of Swift? Do you think Swift is our future in some areas?

P: By now this should be less surprising. I was already doing Objective-C, but had also branched into other languages like D and F# – and had my eye on Rust and Go. The idea of a thoroughly modern language for iOS and Mac development was exactly what I’d been wishing for – but never thought we’d actually get it. I was very excited when Craig Federighi announced it onstage at WWDC two years ago.

The first release was very promising, but still had a few rough edges and shortcomings. Swift 2.x plugged a lot of those – especially on the error-handling front. I usually describe the Swift 2.x solution as “checked exceptions done right” – although it’s a lot more than that. Swift 3.0 plugs even more – but has also been a big clean-up effort, removing inconsistencies, dropping legacy naming (when mapping framework functions in from Objective-C) and getting as many source-compatibility-breaking changes out of the way as possible. Swift 3.0 should now be a lot more stable in terms of language changes – most planned changes now are purely additive. This means that many projects, especially larger ones, that have been holding back should now start to adopt Swift. There’s a lot of love in the community for Swift and I think it has a bright future – certainly on Apple’s platforms – but even beyond. IBM are heavily investing in Swift on Linux now. They even have an Open Source web framework written in it: Kitura.

As a language, Swift draws on many features found in languages like Rust and Go. But it also has a lot in common with JetBrains’ own Kotlin. Both are pragmatic languages that borrow a lot from the functional world without committing to being a functional programming language.

A: Your personal blog says, “All problems in computer science can be solved by another level of indirection.” That’s quite an interesting principle. Could you comment on it?

P: This is the famous quote from David Wheeler and refers, in general, to our use of abstraction to solve problems. It is most commonly associated with the use of pointers or references, but is more general than that. I particularly like Kevlin Henney’s modification, where he adds, “except for the problem of too many levels of indirection.” I’ve touched on the problems of over-abstraction in a talk I give about Simplicity, for example here.

I was quite surprised when I found, some years ago, that the domain name was unclaimed – so I quickly took it. Of course I had to also register extralevelofindirection.com – which just redirects to levelofindirection.com (and I never get tired of pointing that out).

A: You are an author of Catch, an open source unit test framework for C, C++ and Objective-C. Could you please share the main idea behind it? How is it different from other popular unit testing frameworks?

P: So if you go back to when I was testing and refactoring my first iPhone app, at the time there was only really one test framework in town: OCUnit – which was still a third-party framework with poor integration. It was such a pain to use that I started toying with the idea of using a C++ test framework via Objective-C++. Objective-C++ is a bridging language that allows you to mix C++ and Objective-C in the same source code. So I started evaluating C++ test frameworks – including some I’d used before – but still didn’t really find anything I liked. In particular they all seemed complex to use and hard to set up. I started to get that feeling familiar to most developers, “how hard could it be? I could knock something up in a weekend!”. So I started playing with some ideas for my own test framework – written in C++, but fully compatible with Objective-C too. I had some specific ideas in mind, such as using natural C/ C++ expressions instead of the set of ASSERT_xxx macros that are usually found – but still wanted to capture values of the left-hand-side and right-hand-side independently. I was trying to do it with multiple macros at first – which was horrible. Then I saw Kevlin Henney achieving the same thing with expression templates and I realized that was the way to go! I also borrowed his idea of Sections (although he originally called them Dividers) and they became key features of what became Catch. But it was two other features that probably contributed most to its popularity: (1) it’s header-only – and a single file at that, and (2) in general everything is simple to use and low-friction. You can download the file from GitHub and start using it in real code in less than a minute!

More recently a few other great frameworks have been appearing that have many, if not all, the same advantages. So the competition is heating up – but I’m happy about that. I think everyone benefits. That said I’ve now started on Catch2, which drops support for pre-C++11 compilers in favor of a much simpler, easier to work with codebase internally – as well as support for things like threads.

A: How do you see your responsibilities as a Developer Advocate in JetBrains? What are you planning to start with?

P: I like that JetBrains uses the term “Advocate” instead of the more common “Evangelist.” Advocate implies (to me, at least) a two way relationship. As well as representing the company and its products to the community I’ll be representing the community to the company. So staying part of the community is a big part of it – and that’s something I love! That includes continuing to give talks at conferences, meetups, and other events – and I have a few lined up already – writing more blog posts – both to my personal blog, as well as the official JetBrains blog now too – and continuing to maintain my open source software – especially Catch and Catch2. JetBrains are smart enough to realize that for me to stay relevant I need to keep up a healthy ratio of real coding. In addition I’ll be doing screencasts and webinars that are more focused on the products themselves.

A: Let’s talk about tools now. What do you usually use? When did you first learn about JetBrains tools?

P: I’ve been a long time user of Visual Studio on Windows (back from when it was just the Visual C++ IDE) – and before that Borland C++. On the Mac I’ve been using XCode, but when AppCode first launched I was keen to try that out too as I was already familiar with ReSharper from my C# days. I’ve also been a user of TeamCity for a few years and was a factor in us using it in my previous role – where I was also promoting ReSharper C++ when that launched. So in a way I’ve been an advocate for JetBrains products for a few years already. I’ve had my eye on CLion since it launched but only started really using it more recently as I’ve been writing Catch2 with it exclusively. This works really well because the CMake project can be used to generate other build system projects, so is ideal for cross-platform development – even when using compilers that CLion itself does not yet support (such as Visual C++).

A: Could you share your favorite feature in CLion, AppCode or ReSharper C++? What do you most like about them?

P: My previous role involved quite a large, complex, code-base – over a million lines of code, split across about 40 projects. It was a Visual C++ solution so I tried ReSharper C++. Having reliable code navigation across all that was a huge win. Similar tools I’d used before hit more limitations when dealing with template specializations and overloads. Closely related were the refactoring tools – especially Rename – which, again, worked reliably. What I like most about these features is that they reduce friction when working with the code-base. We often talk about how much time is saved but that’s not necessarily a good metric. When most of your development time is spent waiting for builds, stepping through code in a debugger, writing emails and talking to other developers, actual coding time is a small part of an average day overall. But when you are “in the zone,” having things at your fingertips instead of minutes or seconds away makes all the difference.

A: Thanks for the interview, Phil. We wish you all the best at your new position and look forward to working together!

Follow and ping Phil on Twitter and feel free to catch him at conferences and ask your questions.

]]>https://blog.jetbrains.com/rscpp/introducing-phil-nash/feed/1What’s New in ReSharper C++ 2016.2https://blog.jetbrains.com/rscpp/whats-new-in-resharper-c-2016-2/
https://blog.jetbrains.com/rscpp/whats-new-in-resharper-c-2016-2/#commentsWed, 14 Sep 2016 11:00:22 +0000http://blog.jetbrains.com/rscpp/?p=202As a part of ReSharper Ultimate 2016.2, our C++ team is happy to present the ReSharper C++ 2016.2 update. All in all, the new release comes with 200+ fixes and resolves several important performance- and stability-affecting issues. Let’s take a … Continue reading →

]]>As a part of ReSharper Ultimate 2016.2, our C++ team is happy to present the ReSharper C++ 2016.2 update. All in all, the new release comes with 200+ fixes and resolves several important performance- and stability-affecting issues. Let’s take a tour of the new features in this release.

Inline Variable

The mainline ReSharper’s refactorings continue to make their way into ReSharper C++. With the latest update, Inline Variable is now available for C++. This refactoring allows you to replace all occurrences of a variable in the code with its initializer. (The reverse functionality is already provided by the Introduce Variable refactoring.)

Doxygen support

Doxygen is arguably the most popular format and tool for code documentation in the C++ world. ReSharper C++ now understands Doxygen syntax, and provides several key features to facilitate editing of documentation blocks:

Typing assist helps with creating new comment blocks and maintaining the structure of existing ones.

Function parameter references introduced with \param commands will be reported by Find Usages and will get updated when Rename is used to change a function parameter’s name.

Warnings are issued when function parameter references do not resolve to an existing function parameter.

Documentation generation

You can now generate documentation for C++ declarators, classes and macro definitions. Since parsing a C++ file can require a significant amount of time, to avoid UI freezes this feature is implemented via a context action available when using Alt+Enter on the entity’s name.
When the action is applied, ReSharper C++ uses the builtin doc live template to generate the resulting comment. The default documentation template is configured to be compatible with Doxygen syntax, but it can be customized (as usual) using the Templates Explorer tool window. An assortment of specialized documentation macros can be used inside the template, which evaluate to:

Short or qualified name of the entity that is being documented.

Function/macro/template parameter name or type (the containing template line is duplicated for each corresponding parameter).

Function return value, if there is one.

Quick Documentation

Thanks to Doxygen support, Quick Documentation now works in C++. The documentation pop-up (bound to Ctrl+Shift+F1 in the Visual Studio scheme or Ctrl+Q in the IntelliJ IDEA scheme) will display documentation from Doxygen comment blocks, or the symbol’s signature if no documentation is found.

Code analysis

ReSharper C++ now understands several of the standard C++11 attributes and their Visual C++ counterparts:

Usages of functions and classes marked with [[deprecated]]/__declspec(deprecated) are reported together with the specified reason.

Not all control paths return a value and other control-flow based analyses correctly handle functions marked with [[noreturn]]/__declspec(noreturn).

Most header files should start with some form of include guard to avoid multiple inclusion. Similar to the Missing precompiled header include for .cpp files, ReSharper C++ will now warn you if a header file lacks an include guard and will provide a fix to automatically add a #pragma once directive.

Omitting noexcept specifications from user-defined move constructors and assignment operators can have serious performance implications (for an in-depth discussion refer to this blog-post or Item 14 of Scott Meyers’ excellent “Effective Modern C++”). To make sure this is intentional, ReSharper C++ will warn you about move constructors, move assignment operators and swap functions without an explicit noexcept specification, with corresponding fixes to add one.

Starting with Visual Studio 2013, the Visual C++ compiler has supported explicit user defined conversions. To complement the existing Non-explicit converting constructor inspection, Non-explicit conversion operator was added. Severity for both analyses is set to Hint by default (so they are not shown as suggestions), but can be increased if you prefer to avoid implicit user-defined type conversions.

In addition to suggesting to replace zero constants with nullptr in pointer contexts, ReSharper C++ will also offer replacing integral constants with true/false in boolean contexts.

Last but not least, another new inspection detects missing default cases in switch statements and provides a fix to insert it. The same fix is also available for the Uncovered enumerators inspection.

Go to Text

A new member of the Go to family, Go to Text navigation (Ctrl+T,T,T in the Visual Studio keyboard scheme or Ctrl+N,N,N in the IntelliJ IDEA scheme), lets you quickly find and navigate to any text in source and textual files in the entire solution.
This new feature uses trigram indexing to make text search blazing-fast. Similar to other navigation commands, if there are too many matching items you can press + on the numeric keypad to explore results in the Find Results window.

New code style options

New formatter options provide support for some commonly used styles in C++ code:

The Braces Layout | Keep simple compound statements in one line setting was added to allow single-line definitions of trivial functions. It can be set to force ReSharper C++ to make such functions single- or multi-line, or to simply not change their formatting.

A related setting, Blank Lines | Around single line function definitions, controls the number of blank lines that a single-line function should be surrounded with.

The Wrapping and Aligning | Break line before member initializer list option controls whether to start member initializer lists on a new line.

Different projects use different conventions for the syntax of #include directives – as a result, we received several requests to make auto-generated #include directives more customizable. ReSharper C++ now provides preferences about whether to insert paths relative to the current file and when angle brackets should be used instead of quotes.

A couple of settings were added specifically for compatibility with pre-C++11 codebases:

Formatter gets an option to require a space between closing angle brackets in template arguments, to avoid a notorious parsing issue in C++98.

Instead of nullptr, ReSharper C++ can be configured to use NULL or 0 for default pointer initializers.

Generate improvements

In addition to Google Mock, the mock function generator now supports Trompeloeil. Trompeloeil is a modern header-only C++14 mocking framework, and is a great alternative to Google Mock when your project needs a mocking library but does not use Google Test. As with Google Mock, the generator becomes available when ReSharper C++ detects that the library is included into the current source file.

Similar to relational operators, the equality operator generator now has an option to use std::tie.

The constructor generator now lets you specify the accessibility of generated constructor(s) (starting with ReSharper C++ 2016.2.1).

Auto-import completion

Code completion in C++ became integrated with auto-import and can suggest symbols that are not included into the current file. The necessary #include directives are added automatically when an auto-import item gets used.
Please note that auto-import items get added into the completion list asynchronously, so they will be available after a short delay.

Code template enhancements

If you need to surround a piece of code with a template, just select the code and type in the name of the template you need: no extra shortcuts required. Furthermore, a single template can now be used for creating code (as a live template) and for surrounding existing code (as a surround template).

The default C++ class and struct file templates now contain a macro that expands into an #include directive for the precompiled header file, if the project uses one.

Odds and ends

Keeping up with the language evolution, ReSharper C++ extends its support of the C++14 standard. In particular, variable templates and decltype(auto) are now supported.

When your caret is on one of the exit points of a function/loop/switch (return, throw etc.), ReSharper C++ will automatically highlight all other exit points.

Similar to Visual Studio’s __INTELLISENSE__ define, ReSharper C++ now defines its own __RESHARPER__ macro in the internal preprocessor implementation. If necessary, this definition can be used to guard code that ReSharper C++ does not understand for some reason, or to hide parts of a file from code analysis.

CppCon 2016

If you are attending CppCon 2016, be sure to stop by the JetBrains booth September 20-21! Members from both the CLion and ReSharper C++ teams will be present, and we will be happy to tell you all about our products, share future plans and answer your questions. Don’t miss your chance to participate in our license raffle and win a free 1-year subscription for any JetBrains C++ product of your choice!

As always, we would like to hear your feedback – and if you have any problems or feature suggestions, do not hesitate to contact us or create a request in our issue tracker!

]]>https://blog.jetbrains.com/rscpp/whats-new-in-resharper-c-2016-2/feed/3C++ Annotated: Jun – Aug 2016https://blog.jetbrains.com/rscpp/cpp-annotated-jun-aug-2016/
https://blog.jetbrains.com/rscpp/cpp-annotated-jun-aug-2016/#respondWed, 31 Aug 2016 09:45:27 +0000http://blog.jetbrains.com/rscpp/?p=198Today we are happy to share our next compilation of C++ news with you. Subscribe to the regular C++ Annotated and be the first to get the next edition! C++ Annotated: June – August 2016 In this edition: Interviews Conferences … Continue reading →

]]>Today we are happy to share our next compilation of C++ news with you.

Subscribe to the regular C++ Annotated and be the first to get the next edition!

C++ Annotated: June – August 2016

In this edition:

Interviews

Conferences

News & Stories

Releases

Interviews

Jon Kalb speaks about CppCon, C++17 standard and C++ community

These months were quiet in terms of conferences, but September is just around the corner with the most well-known and significant event in the C++ world – CppCon. CLion’s PMM, Anastasia Kazakova, talked to Jon Kalb, CppCon Chair and C++ instructor. The first topic discussed was the C++ community and how modern language features are adopted by it. They went on talking about Jon’s feeling towards C++17 and his strong faith that the committee did everything just right. Jon also shared a secret recipe and a magic ingredient of CppCon success and a story of CppCat, and spoke about the era of tools for C++.

An interview with Sean Parent

Jens Wellers from Meeting C++ did an interview with Sean Parent. Learn why Sean would select Argument-Dependant Lookup if he could remove one feature from C++ language; why he thinks garbage collection has no place as a part of the general allocation scheme; discover his views on functional programming, smart pointers, coding guidelines and a bunch of other topics.

Stephen Kelly at CppCast

During these months many interesting episodes of CppCast were published. One of them is an interview with Stephen Kelly, Qt and CMake expert and maintainer. He talks about Qt build system and CMake similarities and how they can co-exist. While the most interesting part of the interview is dedicated to CMake API and how tools like IDEs can use it to integrate deeper with CMake, Stephen also answers questions about its design and why they dropped the idea of simply generating more content on a CMake call and decided to use the idea of the CMake server instead. In the end, Stephen shares some tips on CMake productive usage, like creating and using CMake config files.

Another great episode of CppCast worthy of a mention is an episode with Herb Sutter reviewing the results of the Oulu C++ committee meeting.

Conferences

CppCon 2016 program

CppCon 2016 will start in Bellevue, USA, in September. In July the program was announced, bringing a philosophical keynote by Bjarne Stroustrup (The Evolution of C++: Past, Present, and Future), a talk about the concurrency from Anthony Williams, one of the original authors of Boost.Thread and the author of C++ Concurrency in Action, well-known Hans Boehm will be talking about atomics; there will be several talks of interest to the financial industry, thoughts and experience shared by the CppCast hosts in the talk called What We’ve Learned From the C++ Community and more famous names and interesting topics. Have you booked your ticket already?

Meeting C++ 2016

Another C++ conference, Meeting C++ that will be held in Berlin, in November, also published the program. It’s also going to be opened with the keynote by Bjarne Stroustrup, some talks and speakers will be shared with the CppCon program. However, some unique talks are planned as well, for example Phil Nash with Functional C++ for Fun and Profit, trying to see if we can actually do functional programming in C++. Check the program to get more details.

ADC 2016 powered by JUCE

Last year JUCE conference had a huge success and turned this year into the Audio Developer Conference. Julian Storer, the author of JUCE framework, will be accompanied by 30 other great speakers in London in November, talking about modern C++ and its adoption in audio development area, JUCE framework and its usages, as well as several interesting tools and solutions for the area. Check the full program announced on the site.

News & Stories

C++17 Committee Draft

C++17 is just around the corner! After the C++ committee gathered in Oulu, Finland, the final list of C++17 features was built, and the committee finally shipped the Committee Draft, which means that no new features will be added to C++17 from now on. A short summary of the new additions voted into the C++17 working draft at the meeting in Oulu can be found at reddit. It includes dynamic memory allocation for over-aligned data, template argument deduction for class templates, and other features. Check the full list on reddit with the links to the proposals.

Top 15 C++ Exception handling mistakes

Deb Haldar from Microsoft points out 15 mistakes that C++ developers used to make when using the exceptions handling mechanism. He discusses performance and code size criteria, gives a short overview of the stack unwinding process and code flows where exceptions should not be used (since the function can actually recover from the problem). There are also arguments as to why exceptions could be included into constructors and what’s wrong with them in the destructors. More tricky tips include throwing by value, catching by reference, deriving from std::exception or subclasses, and more.

The story of Coati

This instructive story of a Google internship that leads to the creation of Coati, a cross-­platform source explorer for C/C++, touches on the problem all the developers meet. Reading code takes most of the developer’s time and a good instrument is often lacking here. Such tool should make it possible to easily collect information about class instantiations, look up interface implementations, search for function calls, etc. The results output format is crucial as it should be easy to read. This all leads to a popular idea of interactive visualization. If you are interested in the suggested solution, check Coati’s home pages.

Understanding C/C++ pointers

If you ever had hard time understanding C/C++ pointers, this blog might be of interest to you as it includes a nice series of blog posts dedicated to C/C++ pointers, their behaviour and interesting facts that are not that obvious at first glance. Why does the type of the value to which the pointer points matter? How can the value be passed in pointers? Is an array function argument better than a pointer? Find answers in the blog posts dedicated to C/C++ pointers.

Vision for the Future of C++ from LoopPerfect

LoopPerfect is a company behind Jyt, a just-in-time compiler for C++. In their blog they are analyzing programming languages popularity trends and offering one more advantage C++ could have – rapid development times using just-in-time compilation. They suggest the hot reload solution be added to C++. Check their demo to see how it works, and who knows, maybe this will be the future of C++…

C to Rust translation

The Rust language is designed to be safe and concurrent. Its popularity grows fast, especially after version 1.0 was released. Thus projects like Corrode, an automatic semantics-preserving translation from C to Rust, are becoming more popular as well. As stated on its GitHub page, Corrode can be useful for both migrating the legacy code that was implemented in C and serving as a complementary approach to static analysis for C programs. The latter is actually quite interesting. Taking into account that translation can either success or fail, the user can either run checks provided by the Rust compiler (missing from the C one) or suggest that the translation failed because of some potentially hidden bugs and try searching for them.

Refactoring Session from Arne Mertz

In his second session dedicated to code refactoring, Arne Mertz eliminates code smells from a real-world code sample. He pays attention to poor naming; classes derived from standard containers, which is strongly not recommended; some unnecessary manual implementations of the standard algorithms; out-parameters usage instead of a normal return value. The second step was focused on the main algorithm itself, constructing a new class and extracting several separate functions. At the end of the day this sample works as a good tutorial on how to eliminate code smells and refactor them.

Conan virtual environments

Conan, a C/C++ package manager and a part of so-called 4C development environment, posted an article about easy managing of applications that developers use to build software (and especially useful for CI purposes). This is a new feature of Conan 0.11 release and it allows you to easily configure all the parameters of the environments, like the actual set of tools, their versions and options used during installation. There is also a way of creating conan packages for any tool. Check the article to learn more details.

Dogfooding CLion

CLion team shared the story of their collaboration with the Toolbox App team, who is currently one of the CLion’s users inside JetBrains company. The solution manages all JetBrains desktop tools, taking care of installing new versions, cleaning up old ones, getting updates, or rolling back. It consists of a native Qt-based application written in C++, embedded browser (with modern web technologies used) and JSON and Kotlin server side. As CLion covers nearly perfectly all the needs of the client-side part, it quickly became the tool where Toolbox App can be “just opened and started”, despite a few issues.

CppChat episodes

1.5 year ago the C++ community got CppCast, a podcast by C++ developers for C++ developers, hosted by Rob Irving and Jason Turner. And approximately a month ago Jon Kalb (whom Herb Sutter called a rising star in the C++ community) started CppChat, which is a live conversation about the latest news in the C++ world. One can join the Hangout streaming or watch the episodes later on Jon’s YouTube channel. Together with Bryce Adelstein Lelbach, Jens Weller, Matt Calabrese, Howard Hinnant, Richard Thomson and others, they discuss lots of hot C++ topics: Meeting C++ and CppCon’s programs and keynotes speakers, language features and upcoming C++17 standard and committee decisions, Boost, CMake and much more.

PVS-Studio and Linux

PVS-Studio is a code analysis tool that helps users catch bugs in programs in C, C++, and C#. For C and C++ it allows catching problems related to 64-bit usages, arithmetic over/underflows, array index out of bounds issues, double-free situations, unreachable code, unused variables, and much more. After being a Windows-based tool for a long time, with Visual Studio and MinGW language dialects support, it now comes to Linux with plans to support GCC and Clang. In the blog posts Andrey Karpov shares the plans, describing what there is behind compilers support and why it’s not that easy, why they need to get a collection of source code samples with a vast range of language features used, what compiler runs the monitoring system they wish to implement and other related tasks.

Multiple cursors

If you used the Sublime text editor for your development, you probably heard about multiple cursors. CLion has this feature too, adding smarter support to it ( for example, live templates working by multiple cursors). The post from CLion’s blog explains how to work with multiple cursors, as well as lists smart actions that are available by them. It also demonstrates where it’s better to avoid multiple cursors and use refactorings and code generation features instead.

Releases

KDevelop 5.0

KDevelop is back after two years with a fresh release. It now uses Clang for parsing C++, which brings C and Objective-C language support in addition. Clang fix-its help resolve multiple problems detected by code analysis. Another notable change is replacing the hand-written CMake interpreter with parsing the compile_commands.json file generated by CMake. This change makes CMake handling more accurate and swift. Other changes include JavaScript, QMake, Python and PHP official support.

CLion 2016.2

The second major update this year for CLion brought lots of long-awaited features like remote GDB debug (on Linux and macOS) together with dozens of debugger fixes and performance improvements, the Doxygen support (including function and function parameters renaming with automatic update of Doxygen references, completion and comment stubs generation), operators generation, several smart features for CMake. It also includes IntelliJ-platform improvements like font ligatures, background images, VCS patches workflow improvements and more. Check the overview demo to learn about new features and read details in CLion’s blog.

If you are wondering what’s next and looking for the ability to watch the command output during CMake execution, remote debug on Windows, user-defined literals support and other requests, check the roadmap post.

ReSharper C++ 2016.2

ReSharper C++, Visual Studio Extension for C++ Developers also came with a second major update this year. ReSharper C++ 2016.2, as well as CLion, shows the Doxygen documentation in the newly added Quick Documentation pop-up. Doxygen comments stubs generation, completion, find usages and rename refactoring are supported as well. Apart from the documentation features, ReSharper C++ introduced several new inspections and quick-fixes and new code style settings. Autocompletion adds the missing includes, so you can complete symbols that are not yet included in the current file. Find out more details about ReSharper 2016.2 on the site.

Visual Studio Code C/C++ extension update

Ankit Asthana shared some new features added to Visual Studio Code for C and C++ along with another update. The debugger part looks interesting now with LLDB support for macOS and the process picker to attach to a running process. Another great feature is the ability to limit symbol processing to the included headers only to speed up the code-navigation experience. And in case you’d like to share your feedback with the team, there’s a link to the survey at the beginning of the post.

]]>https://blog.jetbrains.com/rscpp/cpp-annotated-jun-aug-2016/feed/0C++ Annotated: March – May 2016https://blog.jetbrains.com/rscpp/c-annotated-march-may-2016/
https://blog.jetbrains.com/rscpp/c-annotated-march-may-2016/#commentsWed, 01 Jun 2016 11:45:45 +0000http://blog.jetbrains.com/rscpp/?p=193Today we are happy to share our next compilation of C++ news with you. Subscribe to the regular C++ Annotated and be the first to get the next edition! C++ Annotated: March – May In this edition: Conferences News & … Continue reading →

]]>Today we are happy to share our next compilation of C++ news with you.

Subscribe to the regular C++ Annotated and be the first to get the next edition!

C++ Annotated: March – May

In this edition:

Conferences

News & Stories

Webinars

Releases

Conferences

ACCU 2016

In April, ACCU came back to Bristol, UK, as usual. The premier UK developer conference this time brought together more than 400 attendees and over 60 speakers. Four playlists with video recordings, one for each day, are already available on YouTube. Lots of interesting topics were covered this year, for example Greg Law’s talk about profound and thus less known GDB features, Diego Rodriguez-Losada’s talk about C/C++ and Python working together, a talk from our developer advocate Dmitri Nesteruk about Design Patterns in Modern C++, and many more.

Besides, ACCU 2016 Chair, Russel Winder, gave JetBrains an interview where he talked about things that make ACCU unique, as well as his experience with Rust, D and Go languages and their future in comparison to C++.

C++Now 2016

Across the pond, C++Now 2016 was held in Aspen, Colorado, in early May. Attendees could find a lot of well-known names from the C++ community joining the event, like Sean Parent from Adobe with a keynote talk about Better code, Jon Kalb with his famous O’Reilly report about C++ landscape overview, Timur Doumler, a JUCE developer from ROLI, Marshall Clow, Barbara Geller, David Sankel, and many others.

Check out the best session winners and learn about C++Now 2017 dates in the blog post.

News & Stories

C++17 standard news

March brought several reports about the C++ meeting in Jacksonville, Florida. Herb Sutter posted a long and detailed one in his blog. Despite many expectations and hopes in the C++ community, modules and concepts won’t come to C++17. However, for now they will both stay in their own technical specification. Coroutines are targeted for another TS as well. On the good side, Herb lists the features that are making their way to the upcoming C++ standard, like Parallel STL and several more TS that were merged into the final C++17 edition, and several features coming directly to the new standard like fallthrough, nodiscard and maybe_unused attributes and more. The future of C++ is presented in Herb’s blog post in a simple timeline, followed by an interesting open-ended question: Will C++ stay on the 3-year cycle or move to a 2-year cycle?

C++11 smart pointers

C++ developers (both students and professionals) can find this blog post useful, as it uncovers 10 dangerous pitfalls when working with C++11 smart pointers. It tells you where it’s better to use shared_ptr, unique_ptr and auto_ptr; how to avoid double memory allocation by using make_shared; and lays out the rules for working with the raw pointers.

lambdas and std::function

C++11 lambdas are already widely used. The idea is pretty simple. The easiest (though probably useless) example is “[](){}();”. But do we know them well enough to answer even basic questions? What is the lambda’s type and why is it not std::function? How long do the variables captured by lambda stay alive? What is the size of a lambda? If you feel like testing your knowledge of lambdas, head straight to this blog post.

Conan

In the previous edition we already mentioned Conan, a C/C++ package manager. This time we’d like to share more information about it. First up is a CppCast episode with Diego Rodriguez-Losada, known as a biicode startup co-founder and currently Conan committer. Watch the episode to learn the Conan story first-hand.

There is also a great post in Conan’s blog for those interested in setting up a full environment for C/C++ development based on Clang as the compiler, CMake as the build system, CLion as the IDE, and Conan as the package manager. Check the steps and follow advices for an easy set-up.

Compiler Bugs Found When Porting Chromium to VC++ 2015

Bruce Dawson from Google posted some great material on the bugs found while porting a big Chromium project from VC++2013 to VC++ 2015. The incredible work includes attempts to build some smaller samples to reproduce the problems, as well as some deeper analysis of the situations. Read the post to know about a problem with zeroing a five-byte array, a crash that would happen only under Profile Guided Optimization, an incorrect 64-bit structure read, and more.

Telemetry function calls in VS 2015

Recently the C++ community has been discussing the telemetry call in every binary compiled in VS2015. The discussion was huge as conspiracy theories are always popular, even though the logs written in that case were quite limited and have to be switched on manually (so not working by default).

However, the discussion on reddit got an official comment. Steve Carroll from the Visual C++ team has promised that the corresponding calls will be removed in Update 3. He explained that the main intent was to build a framework that would help investigate performance problems and improve the quality of the optimizer.

C++ I/O Benchmark

Cristian Adam posted in his blog nice and solid benchmark for C++ cross-platform calls for Input/Output on Windows 10, Kubuntu 15.10 and Raspberry PI2, testing on a huge set of compilers: GCC, Clang, Visual C++ (2013/15), MinGW GCC, Cygwin GCC and Cygwin Clang. During the test he was reading one file in chunks of 1 MB and writing it to another file. The tested API calls were: C file API (fopen, fread, fwrite), C++ API (std::ifstream, std::ofstream) and POSIX API (open, read, write). And the winner’s crown went to… POSIX. See the full blog post for some interesting numbers.

CppCast

CppCast continues gathering famous C++ community members. Jens Weller talked about the Meeting C++ platform that brings the conference, site and recruiting platform to the C++ world. Get the whole story first-hand. An interview with the author of the renowned blog Simplify C++, Arne Mertz, was recorded for CppCast in March. Find the discussion of the latest standard and more topics in there. April brought an interesting discussion with Ankit Asthana about cross-platform development, Visual Studio Code and Visual Studio for Linux. Elena Sagalaeva (known by the Russian-speaking community for her famous blog on C++ in Russian) attended the podcast in April as well, talking about distributed computing and how the latest C++ standards are useful there.

Webinars

Design Patterns and Modern C++

The recording of our May 24th webinar, Design Patterns and Modern C++, is now available on JetBrainsTV YouTube channel. In this webinar Dmitri Nesteruk shows how the classical design patterns that arose in 1994 from the infamous Gang of Four book continue to be as useful to this day. We are discussing the adapter pattern, the builder pattern and the maybe monad. Several questions from the webinar answered by Dmitri can be found in the corresponding blog post.

Releases

GCC 6.1

The new major release of GCC compiler was announced and brought lots of goodies. First of all, C++14 is set as a default. Besides, many features from the upcoming C++17 were added to the compiler (for both language and standard library), and even Concepts, that were postponed by the committee to another TS, are available in GCC 6.1 via -fconcepts.

Checking the list of the General Optimizer Improvements in the release notes, you may notice an interesting point that C++ developers definitely should heed: “Value range propagation now assumes that the this pointer of C++ member functions is non-null”. You may want to check whether your code base is affected by the change, just as it happened to Qt5, Chromium and KDevelop. Anyway, GCC authors suggest a temporary workaround: -fno-delete-null-pointer-checks.

Clang 3.8

A lot of goodies were delivered with the Clang 3.8 release, including OpenMP 3.1 (and several elements of the OpenMP 4.0/4.5), experimental support for end-to-end CUDA compilation, static analyzer improvements, and more. You can also track the progress of the new features through the Clang 3.9 (in progress) release notes.

ReSharper C++ 2016.1

April brought the release of ReSharper C++, a Visual Studio extension for C++ developers. In addition to Google Test support, Boost.Test is now added, including a built-in test runner. This version allows you to mark your code with TODO, BUG, FIXME or any other pattern you may prefer (configurable in settings), and navigate through the marks easily using a special Todo Explorer.

The release also brought a long list of new quick-fixes and context actions that help improve the code, by suggesting various fixes. One example is when ReSharper C++ detects an uninitialized constructor parameter, it offers a context action to create and initialize the corresponding field. Find more details about the new version in this blog post.

CLion 2016.1

CLion, a cross-platform IDE for C and C++ developers, got an important update. Release 2016.1 finally brought variadic templates support and auto-import for STL symbols. Quick Documentation pop-up was enhanced with the hyperlinks to the related symbols. During debugging users are now allowed to attach to the process running on a local machine but not started from the IDE – all the benefits of the built-in debugger UI are still there.

To speed up the indexing time, CLion 2016.1 lets you mark directories as excluded (several more option like libraries or sources are also available).
Overgrowing just C and C++ development, CLion turns to the multi-languages projects bringing Python and Swift support on board. Feel free to check the details in the CLion’s blog.

Finally, CLion started a new Early Access Program for version 2016.2. This build addresses Doxygen support, Complete Statement and VCS changes, CMake rename refactoring for users symbols and more.

Qt Creator 4

Qt came out with big news in May and released Qt Creator 4.0.0. It includes CMake workflow changes (like automatic triggering when necessary, UI to change the CMake configuration for a build directory and more), automatic use for the Clang code model, Clang static analyzer integration available under open source, fixes for the latest LLDB version and several more improvements.

Visual Studio 2015 Update 2

Microsoft has given us a lot of exciting news in these months. Update 2 comes with many interesting changes for C++ developers. C++ compiler got many bug fixes, with the most notable changes including support for Variable Templates and constexpr improvements. At the same time, many C++17 features have made their way to C++ standard library as well.

However, the biggest improvement is probably for those who develop for Linux, as the new extension makes possible C++ development in Visual Studio for Linux. You can now create projects and manage connections to the Linux machine right from the VS. Upon connecting, VS will copy your sources to the remote Linux machine and will invoke GCC to build the sources with the options from the project properties. Then you can debug your code remotely.

Looking into the future of Visual C++ compiler, read this blog post about upcoming changes in Visual C++ code optimizer. Find out the reasons behind the new optimizer, and see several samples of implemented optimizations.

]]>https://blog.jetbrains.com/rscpp/c-annotated-march-may-2016/feed/1What’s New in ReSharper C++ 2016.1https://blog.jetbrains.com/rscpp/whats-new-in-resharper-c-2016-1/
https://blog.jetbrains.com/rscpp/whats-new-in-resharper-c-2016-1/#commentsTue, 17 May 2016 13:11:41 +0000http://blog.jetbrains.com/rscpp/?p=157Apart from the change in version numbers, ReSharper C++ comes with plenty of new features as well as improvements to existing functionality. Here’s what we’ve got in store for you with this release. Boost.Test Support The previous release of ReSharper … Continue reading →

]]>Apart from the change in version numbers, ReSharper C++ comes with plenty of new features as well as improvements to existing functionality. Here’s what we’ve got in store for you with this release.

Boost.Test Support

The previous release of ReSharper C++ provided a unit test runner for Google Test — well, this one augments this with Boost.Test support. This includes all the usual refinements users of our unit test infrastructure are used to. ReSharper will detect individual Boost tests as well as test suites:

There is also support for test labels:

And of course it will use its unit test runner to actually run those tests and show a listing of the results.

Please note that Boost.Test support requires Boost 1.59 or later.

Todo Explorer

The Todo Explorer is a separate tool window that has long existed in the original ReSharper but is now coming to ReSharper C++. Its goal is to find text that matches a specific pattern in comments, strings or identifiers and show all the located elements in a single, easy-to-browse list:

There are plenty of filtering and grouping options in this window, and double-clicking each element takes you right to the line of code where the relevant piece of information was found. ReSharper comes with support for TODO and BUG in comments, but you can easily add other markers or create new ones:

As the above screenshot demonstrates, you can define the regular expression to search for, the type of code element (comments, strings, identifiers) to search in, and you can also control the color that’s used for this type of item in the Todo Explorer.

Context Actions and Quick-Fixes

As with all releases, we keep expanding the set of context actions and quick-fixes that ReSharper C++ provides. Here are a few examples.

If an out-of-class member function signature fails to match the prototype in the class body, ReSharper C++ now offers two quick-fixes to change that:

Choosing Use signature…, the signature of the function definition will be changed to the one of its declaration. Choosing Change signature… does the reverse, changing the declaration so that it matches the definition.

When ReSharper C++ detects an uninitialized constructor parameter, we now offer a context action to create and initialize the corresponding field

When ReSharper C++ detects possible unintended object slicing, it offers the option to perform a static_cast:

If the type of variable being returned from a function does not match the type in the function signature, ReSharper C++ offers the options to adjust either the return type or the type of variable being returned:

In fact, we have a more general mechanism for detecting type mismatches: for example, assigning an int variable a string literal will present you with the following:

If you try to assign a read-only member in a const function, ReSharper C++ now offers you quick-fixes to either to make the member mutable or make the function non-const:

If a base class or its function has a final modifier, ReSharper C++ will highlight the error over both the final keyword as well as any overriding classes and offer you a quick-fix to make the base class non-final:

New context actions are also provided to flip operator arguments and negate boolean expressions:

We’ve added fixes and context actions for working with includes: analyses related to precompiled header usage, context actions to normalize slashes in include paths, support for replacement of quotes with angle brackets (and vise versa).

In addition to the bulk generate definitions action, we now have bulk Move Function Implementations context action. Simply select several function bodies and press Alt+Enter:

Rename Refactoring Improvements

And there are additional fixes, too. For example, the Rename refactoring now works on files, and will rename both the file as well as any usage (e.g., in #include directives) of the file:

It’s also worth noting that the Rename behavior on an ordinary class will now affect the header/cpp filenames, too.

Code Generation

We’ve made improvements in the code generation functionality. For example, when generating relational operators, ReSharper C++ now offers the option of using std::tie:

Another feature we’ve added to the Generate stream operations feature is the support for the use of Boost for purposes of serialization:

And a Few More Things

Starting with version 2016.1, the Find Code Issues functionality works in the background in both ReSharper and ReSharper C++. This lets you keep editing or navigating your code while ReSharper runs its analysis.

The list of C++ language features supported by ReSharper C++ has also been extended with support for generalized lambda captures, exception specifications and inheriting constructors. We also have formatting options now being taken into account when generating code.

The formatting settings have a new page for controlling blank lines.

Finally, all ReSharper C++ actions are now actively banned from changing the code of any of the C++ libraries that you might be using.

So that’s it! Enjoy the new release of ReSharper C++, and be sure to let us know what you think!

]]>https://blog.jetbrains.com/rscpp/whats-new-in-resharper-c-2016-1/feed/5C++ Annotated: Dec – Feb editionhttps://blog.jetbrains.com/rscpp/c-annotated-dec-feb-edition/
https://blog.jetbrains.com/rscpp/c-annotated-dec-feb-edition/#respondMon, 07 Mar 2016 09:58:13 +0000http://blog.jetbrains.com/rscpp/?p=154Today we are happy to share our next compilation of C++ news with you. To subscribe to regular C++ annotated use this simple form and be the first to get the next edition! C++ Annotated: Dec – Feb In this … Continue reading →

]]>Today we are happy to share our next compilation of C++ news with you.

To subscribe to regular C++ annotated use this simple form and be the first to get the next edition!

C++ Annotated: Dec – Feb

In this edition:

Conferences

News & Stories

Releases

Conferences

Meeting C++

Meeting C++ 2015, the final C++ event in the year, was held in Berlin, December 4 & 5. Focused on Embedded Development this year, it was a great meetup for C++ developers from Europe and all over the world. Lots of interesting topics were covered, from the fantastic opening keynotes by Chandler Carruth about “Understanding Compiler Optimization” and James McNellis talking about “C++ Coroutines” to interesting lightning talks like Daniel Jasper’s about clang-tidy. There is a playlist available on YouTube with all the videos from the conference. Go on and check the topics you are mostly interested in!

By the way, it was great to meet so many C++ developers at our booth at the conference. Thank you for coming up with lots of interesting questions. See you next year!

News & Stories

News in brief

Android NDK switches to Clang and deprecates GCC; GDB updated to version 7.10.

Dmitri Nesteruk shows Cling (C++ interpreter) and Google Tests, while building a simple order book in C++. Watch the video on the YouTube.

Another survey from the Microsoft team is online. This time the team wants you to share your game development experience and talk about which languages, IDEs and game engines you use.

Rust published an RFC describing their ideas to modify the compiler in order to support IDEs.

CppCast

CppCast, the first podcast by C++ developers for C++ developers, hosted by Rob Irving and Jason Turner, celebrates 1 year on air! Nearly 50 episodes published, covering the vast majority of C++ topics and introducing a great number of well-known guests: starting from Jon Kalb in episode 1 (he is back in episode 35 talking about CppCon), going further with Scott Meyers coming to episode 26 with a traditional topic about effective C++, then Andrei Alexandrescu about D, Eric Niebler about Ranges, Steve Klabnik about Rust, and many other fantastic guests. JetBrains was on air in episode 5 with Anastasia Kazakova talking about CLion (an upcoming C/C++ IDE at the time) and in episode 34 with Dmitri Nesteruk about High Performance Computing, CLion, ReSharper C++ and many other questions. Check the archive of episodes and let’s wish CppCast another great year!

Notes on C++ SFINAE

In his blog post about C++ SFINAE (Substitution failure is not an error), Bartlomiej Filipek tries to provide a short and clear explanation of what it is and when one can use it. Since the concept is not that easy, it’s important to understand the process of building the overload resolution set for a function call and how it works with SFINAE.
The simplified scheme from the blog post can help a lot, as can with the nice set of usage samples.

Visual C++ and C++17

Stephan T. Lavavej provides a detailed overview of all the new language features for C++ standard library and answers some frequently asked questions on the topic in the Visual C++ blog. The main point is that C++17 STL features have made their way into VS 2015 update 2. As usual, Microsoft has shared a nice graphical representation of the supported set of features so you can easily check if a particular standard feature is supported and in which version.

There is also an interesting FAQ section that explains how STL development impacts compiler features and why it makes sense to work on C++17 in STL ahead of finishing compiler features from the previous standards. And by the way, all these STL changes will be available in the Community Edition as well.

C++ in 2016

Jens Weller (from meetingcpp.com) in his annual post about the upcoming year collects important dates, lists C++ conferences, overviews tools trends, libraries and user group news for 2016. There are 8 big conferences, including ACCU in Bristol in spring, CppCon in Bellevue in fall, and Meeting C++ at the end of the year, and 3 C++ Committee meetings. Jens lists some free tools you should know about (like various clang sanitizers) and shares hopes for C++11 being “fully implemented on all major toolsets” during the year, especially with the libraries and tools moving towards C++11 more actively.

CLion: A Review of Feature Usage

Trying to understand how our customers are using CLion, the team has looked back at 2015, the first year for CLion on air. With 45K active users per month and around 16% of them reporting their statistics, we’re getting a pretty good feel for the user experience. Some key facts include:

40% of our users are on Linux, where Ubuntu 14 dominates as the main Linux distribution.

On Windows, MinGW 3.21 is the most popular choice.

‘Go to declaration’ wins as the most popular navigation feature, View parameter info leads among code assistance features, and Rename is again on top of all refactorings.

See the full report for more numbers about popular plugins, VCS usage and other stats.

Swift vs C++

After Apple open-sourced Swift (making it available not only on OS X, but on Ubuntu as well) and let developers contribute to Swift compiler and standard library, LLDB for Swift, and more, many OS X and Linux developers have joined the activity. There is even such a big initiative like IBM experimenting with Swift on Linux host environments. And seeing how some of the tasks that developers usually do using more classical languages like C++ are tested on Swift now, the question of performance comparison becomes essential.

Performance comparisons between Swift and C++ are appearing from time to time. Anthony Schmieder posts the results of Primate Labs tests in their blog regularly. The test is done on three problems with different targets: Mandelbrot (compute bound), GEMM (memory bound, sequential access of large arrays in small blocks), and FFT (memory bound, irregular access of large arrays). It’s interesting to see how the Swift language evolves in terms of performance and with every update inches closer to C++. The author also tries to understand the drawbacks and check some patches. Results from 2014 and 2015 are available, and we very much look forward to this year’s findings.

By the way, you can prepare and run some tests yourself, which is pretty easy now that CLion supports Swift in addition to C and C++. Find out more about the plugin.

libclang performance

Another performance story is about speeding up libclang on Windows. The story starts with… Qt Creator code completion! libclang is used to provide completion support, and with Qt Creator’s clang code model statistics you can compare the performance of such completion using various libclang instances.

C++ package and dependency managers

There is a trend for a programming language/technologie to have a package and dependencies manager. C++ is not exception, though there is no standard one.

For Windows only it’s NuGet, while in cross-platform cases there is some variety. An interesting trend among all is growing usage of CMake.

First cross-platform tool to mention is biicode. Although the company behind it no longer exists, it is a great project (you can find it now in a repository on GitHub). Biicode made it possible to reuse any single source file from any given project in any other project you are developing (and it’s VCS independent), also providing a cloud to host your source code. So it was a cross-platform dependency manager and a hosting tool.

Biicode as a company is gone, but the contributors are still here. One of them is now working on Conan, a C/C++ dependencies and package manager. Growing out of a very similar idea, Conan still differs from biicode: it’s decentralized, allows working with pre-built binaries, and is independent from the build system (though it uses CMake a lot. Conan also provides a hosting service, which is free for OSS.

Of course there are many more options, like CPM, a CMake toolset based on Git, though without any hosting provided. Or Hunter – another cross-platform project based on CMake and using ExternalProject_Add function as its main instrument.

Having said all that, do you use a dependencies and package manager in your project? Which one? Let us know in the comments below.

Releases

Qt Creator

In the middle of December Qt Creator 3.6.0 was released. The most interesting C++ related change is Clang Fix-its which is now integrated into Qt Creator’s refactoring actions. They’ve also added an editor for UML-style diagrams, and improved Qt Quick Designer and QMake configuration type.

Qt Roadmap for 2016 was published in February, highlighting its focus of development for this year. There are changes in the open source licensing that could be interesting (introducing LGPLv3), wider usage of C++11 in modules and Qt libraries planned, and Advanced Profiling, Static Analyzer and Qt Quick Designer features making their way into the open source version of Qt Creator 4.0.

QuantLib

QuantLib, an open-source library for quantitative finance, published a new release in November along with a bug fix update in January. At the same time Dmitri Nesteruk, JetBrains developer advocate, started working on porting QuantLib, which is originally configured as a Visual Studio solution, to CMake model. He posted about it in December (the post also includes some tips about building Boost on Windows) and then provided a pull request that was accepted to QuantLib master, adding initial CMake support to it.

CLion public preview

A new CLion version is going to be released in early spring and now the free Public Preview is available. It finally supports variadic templates and provides proper auto-import for STL symbols, as well as makes generation actions more accurate and their behavior a lot clearer. There are also Python and Swift plugins, and a new ‘attach to local process’ feature for more effective debugging.