Partners: KDAB Whole Tomato Software CppDepend

11 December 2017

How a weak_ptr might prevent full memory cleanup of managed object

Weak pointer and shared pointer

When I was working on the Smart Pointer Reference Card I run into a quite interesting issue. It appears that in some cases memory allocated for the object controlled by smart_ptr might not be released until all weak pointers are also ‘dead’.

Such case was surprising to me because I thought that the moment the last share_ptr goes down, the memory is released.

Let’s drill down the case. It might be interesting as we’ll learn how shared/weak pointers interact with each other.

04 December 2017

5 ways how unique_ptr enhances resource safety in your code

unique_ptr

Modern C++ stresses the use of RAII objects to manage resources. One of the easiest ways is just to start using unique_ptr across your code.

Let’s see how we can leverage this smart pointer type. I’ve come up with 5 (or more?) reasons where unique_ptr shines.

27 November 2017

Summary of C++17 features

Summary of C++17 features

How do you see the new C++ standard? Is it ok? Great? Meh?

Last week, after a few years of break, I presented my new talk that addressed the above question! It happened at the Cracow C++ Local Group.

Have a look what’s inside this talk.

20 November 2017

code::dive 2017 conference report

Code::Dive 2017 report

This year I had a chance to visit Wroclaw for the 4th edition of Code Dive! Two days of a great programming conference!

Briefly: many of topics related to C++, two days, 40 presentations, lots of people and a beautiful city. What more do you need? :)

Continue below to read my report from the event.

06 November 2017

Enforcing code contracts with [[nodiscard]]

nodiscard attribute C++17

For my article series about C++17 features, I’ve made a separate entry about new attributes. At first sight, I thought that [[nodiscard]] is just another simple and a rarely used thing. But later I thought… hmmm… maybe it might be valuable?

One reason is that [[nodiscard]] might be handy when enforcing code contracts. That way you won’t miss an important return value.

Let’s look at a few examples.

30 October 2017

Better code understanding with Sourcetrail

Sourcetrail, review

Do you write code 100% of your job time?

I’m guessing the answer is no. Ignoring the whole management part, meetings, coffee, youtube, cats, etc, even if you’re sitting at your keyboard you’re not typing all the time. So what else are you doing?

The short answer: you’re probably figuring out what to write and where to add new features (and what to fix)… so you’re mostly reading and trying to understand the code.

There are tools to help you better understand code which are not just text editors. One of such application is Sourcetrail, let’s see what can it do for us.

Bonus!, read further to see details of our new giveaway :)

23 October 2017

Expressive C++ Coding Challenge Results

Expressive C++17 challenge Results

Three weeks ago with Jonathan from Fluent C++, we announced a coding challenge: link here.

Let’s meet the winner and discuss some of the best solutions

(Our choice is quite surprising! See why :))

16 October 2017

How not_null can improve your code?

not_null examples

One of the key points of modern C++, as I observe, is to be expressive and use proper types. For example, regarding null pointers, rather than just writing a comment:

void Foo(int* pInt); // pInt cannot be null

I should actually use not_null<int *> pInt.

The code looks great now, isn’t it? Let’s investigate what not_null (from the Core Guidelines/Guideline Support Library) can do for us.

09 October 2017

Cpp Con 2017 Notes

Notes from Cpp Con

Have you been at Cpp Con this year?

I haven’t, but still I plan to watch some good C++ talks. Can you help me a bit and add your notes?

25 September 2017

The Expressive C++17 Coding Challenge

The Expressive C++17 coding challenge

Let’s put C++17 in practice!

One of the good ways to do it is to take part in a coding challenge.
So together with Jonathan Boccara from Fluent C++ we invite you to participate in “The Expressive C++17 coding challenge”.

18 September 2017

C++17 in detail: Summary & Bonus

C++17 features, summary

The last post in the series about C++17 (STL utils) was posted on 4th September. It happened to be just two days before the final C++17 spec was approved! :)

C++17 is formally approved
2017-09-06 by Herb Sutter
herbsutter.com/2017/09/06/c17-is-formally-approved/

In this post, I’d like to make a little summary, and I also have a bonus for you :)

11 September 2017

Learning from bugs and PVS-Studio Team

PVS Studio Resources

Real life:

Fixed 1 out of 99 bugs in a project. 117 to go…

Have you experienced something similar? Although it’s impossible to write bug-free code, there are tools and practices to lower the rate of mistakes.

Today, I’d like to run through a gigantic list of freely available resources from the PVS-Studio Team who works with bugs analysis on a daily basis.

04 September 2017

C++17 in details: Standard Library Utilities

C++17 features, stl utils

The new C++ standard brings many useful additions to the Standard Library. So far we’ve discussed bigger features like the filesystem or parallel algorithms. Today, I want to focus on smaller, but also handy things.

For example, there are utils for handling type safe unions, replacement of void*, string searchers and much more.

28 August 2017

C++17 STL Cookbook Book Review

C++17 STL Cookbook Review

C++17 is on the way, and I’m glad to see more books that stay on the bleeding edge of C++ adaptation. Today I’d like to present a book that focuses on the Standard Library.

Is this another great book?

TL; DR: Yes :) But read more to see why :)

Plus I have a bonus: Q&A with the author and a giveaway.

© 2017, Bartlomiej Filipek, Blogger platform
Any opinions expressed herein are in no way representative of those of my employers.
This site contains ads or referral links, which provide me with a commission. Thank you for your understanding.