Alternative to select-many bitmask -- Krzysztof Ostrowski

Classic interfaces that use bitmask to select many properties at once can be hard to use and very easy to break.

Alternative to select-many bitmask

by Krzysztof Ostrowski

From the article:

Suppose we have an interface that returns some value depending on combination of other values, and we would like get resource of some type R that is common for Alice and Bob. Here is our interface:

R query(std::uint32_t bitmask);

First question arises quickly: what to put into bitmask? There are plenty of values of type uint32_t!

Multiple possible ways to fix our interface and make it much easier to use exist. We will consider three of them.

Add a Comment

Comments are closed.

Comments (0)

There are currently no comments on this entry.