Get the latest tech news

C++: Maps on Chains


(From a conversation with Vassil Vassilev.) Suppose we want to have a C++ map where the keys are disjoint, integer intervals of the form [ a...

In layman terms, a strict weak order < behaves as the "less than" relationship does for numbers, except that there may be incomparable elements x, y such that x ≮ y and y ≮ x; for numbers, this only happens if x= y, but in the case of a general SWO we allow for distinct, incomparable elements as long as they form equivalence classes. In mathematical terms, our relationship is of a more general type called a strict partial order. A strict reading of the standard would not allow this workaround, as it is required that the comparison object for the map induce a strict weak ordering for all possible values of Key, not only those in the container (or that is my interpretation, at least): for all practical purposes, though, this works and will foreseeably continue to work for all future revisions of the standard.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of Maps

Maps

Photo of C++

C++

Photo of chains

chains

Related news:

News photo

Jank is C++

News photo

No More Shading Languages: Compiling C++ to Vulkan Shaders [pdf]

News photo

String Interpolation in C++ Using Glaze Stencil/Mustache