- Follow Andrzej's C++ blog on WordPress.com
Tag Archives: optional
A moved-from optional
This post is in response to claims, that I have heard number of times, that the semantics of optional’s move operations are wrong: Some people are surprised that the second assert holds: the unfulfilled expectation is that moving from an … Continue reading
Posted in programming Tagged optional, performance, resource handling, value semantics 1 Comment
Efficient optional values
In this post we will see a library for storing nullable/optional values that can in certain situations replace and outperform Boost.Optional.
Posted in programming Tagged C++11, correctness, optional, performance, type system 9 Comments
Set-up and tear-down
Recently as part of program run-time performance optimization effort, I was scanning through the code for occurrences of keyword new. The goal was to find unnecessary memory allocations. I was surprised to find most of news in the unit test … Continue reading
Posted in programming Tagged C++03, optional, resource handling 5 Comments
A gotcha with Optional
This post is about one gotcha in Boost.Optional library. When starting to use it, you might get the impression that when you try to put optional<T> where T is expected, you will get a compile-time error. In most of the … Continue reading
Posted in programming Tagged Boost, correctness, gotchas, optional 22 Comments
Today I want to share with you a more philosophical issue I face with how the meaning of operator< is overloaded in C++. This could cause subtle bugs in programs.
Posted in programming Tagged C++03, correctness, generic programming, gotchas, optional 18 Comments
This post is intended to be a light introduction to certain C++ guru tricks. I want to introduce a couple of concepts that typically put normal people off. If you are an expert you will probably not learn anything new, … Continue reading
Posted in programming Tagged advanced-c++, C++03, C++11, c++17, concepts, optional 26 Comments
In this post I want to describe a small language feature added in C++11 that, although essential for full value semantics support, is often neglected in tutorials and in compiler implementations.
Posted in programming Tagged C++11, c++14, optional 6 Comments
Beware of magic values!
Update. The advice I gave below using Boost.Optional was invalid and potentially bug-prone. It is now changed, to reflect my experience with using Boost.Optional. In this post I wanted to show, by a not-so-short example, how the decision to signal … Continue reading
Posted in programming Tagged Boost, C++03, correctness, optional Leave a comment