Tag Archives: Boost
Reflection for aggregates
An aggregate is an array or a class with no user-declared or inherited constructors, no private or protected direct non-static data members, no virtual functions, and no virtual, private, or protected base classes. Aggregates can be initialized in aggregate initialization, … Continue reading
(Not) detecting bugs
The following code contains a bug. A developer has spent quite some time looking for the source. The intent of this code is to iterate over two vectors simultaneously, from the first up to the one-before-last element. Thus the most … Continue reading
Another polymorphism
In this post we will try to see by a practical example what Boost.Variant is for. You can sometimes see examples that use type variant<int, double, string>, but to me they are artificial: I never needed to use something that … Continue reading
Handling short codes — part I
In my work, we often deal with codes: country codes, airport codes, airline codes, aircraft codes, and more. The thing they have in common is that they are really short. Sometimes 2-letter long, sometimes 3-letter long, sometimes a bit longer. … Continue reading
String’s interface
What I have to say today is fairly obvious, and you probably know about it. But because I have observed the following pattern in my project’s code fairly frequently, I feel it needs to be recorded. Consider this code: Can … Continue reading
A gotcha with ptr_vector
Recently I came across an interesting gotcha with Boost.Pointer Container library in my project. Making some incorrect assumptions as to what the library does could cause a bug. What would you use boost::ptr_vector for? Why would you need to have … Continue reading
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
Boost Library Incubator
Update. This post was written in 2014. In 2021 Boost Library Incubator is shutting down, as per this notice. Today, I wanted to draw your attention to the new initiative driven by Robert Ramey: Boost Library Incubator. It is a … Continue reading
Inadvertent conversions
Today I want to warn you about a bug in Boost.Rational library. This illustrates a certain danger connected with allowing convenience conversions from other types.