Memory corruption is the symptom of a program that writes into the wrong memory location. There are a few different classes of bugs that can lead to memory corruption such as uninitialized memory, dangling pointers and buffer overflows. Recently, I’ve discovered a variety I had never seen before, which I’d consider a subclass of buffer overflows. Here’s the short story.
Predicates are functions that return a boolean result upon being called. A predicate example is a function bool isToday(Date& date)
which returns if the supplied date object corresponds to the current day or not. The Standard Template Library (STL) has many algorithms to which predicates can be supplied : count_if
, find_if
, copy_if
, remove_if
, etc. You might have noticed the examples I have given share the suffix _if
which hints to the presence of an argument which is a predicate. In this article, I will go over many different ways to implement a predicate that can be supplied to the STL algorithms in order to extract some elements from a collection. First, here is the collection that will be filtered :
I have been exploring some particular use cases with boost ICL’s interval_map in order to map values to intervals based on a dynamic finite domain. I would like to share what I have learned in the process so I will start with a quick overview of a few concepts of the ICL and then show some code snippets to get it working.