Commit Graph

14 Commits

Author SHA1 Message Date
Konstantin Osipov
4d214b624b lwt: ensure enum_set::of is constexpr.
This allows using it to initialize const static members.
Message-Id: <20190930200530.40063-2-kostja@scylladb.com>
2019-10-01 19:45:56 +02:00
Piotr Sarna
989c31f68b cql3: allow adding enum_sets
Enum set can now be added to another enum set in order to create
a sum of both.
2019-07-29 17:15:51 +02:00
Tomasz Grabiec
f33f0d759d enum_set: Introduce full() 2019-04-28 15:50:12 +02:00
Jesse Haber-Kucharsky
f4fc12fbf0 enum_set: Add iterator
Sometimes it is useful to be able to query for all the members of an
`enum_set`, rather than just add, remove, and query for membership. (The
patch following this one makes use of this in the auth. sub-system).

We use the bitset iterator in Seastar to help with the implementation.
2018-02-14 14:15:59 -05:00
Jesse Haber-Kucharsky
bbe09a4793 enum_set: Throw on bad mask
`super_enum::valid_is_valid_sequence` determines if the numeric index
corresponding to an enumeration value is valid. This is important,
because it is undefined behavior to cast an invalid index into an
enumeration value.

This function is used to check the validity of the `enum_set` mask when
an `enum_set` is constructed in `enum_set::from_mask`. If the mask has
set bits that correspond to invalid enumeration indicies, then we throw
`bad_enum_set_mask`.
2018-02-14 14:15:59 -05:00
Pekka Enberg
38a54df863 Fix pre-ScyllaDB copyright statements
People keep tripping over the old copyrights and copy-pasting them to
new files. Search and replace "Cloudius Systems" with "ScyllaDB".

Message-Id: <1460013664-25966-1-git-send-email-penberg@scylladb.com>
2016-04-08 08:12:47 +03:00
Avi Kivity
d5cf0fb2b1 Add license notices 2015-09-20 10:43:39 +03:00
Tomasz Grabiec
6c3d57696f enum_set: Introduce enum_set::of<>() 2015-04-15 20:33:49 +02:00
Tomasz Grabiec
a720f24c3c enum_set: Introduce frozen<>::unfreeze() 2015-04-15 20:33:48 +02:00
Tomasz Grabiec
57e74d2096 enum_set: Introduce set_if()
This:

  set_if<item>(cond);

is a more efficient version of:

  if (cond) {
     set<item>();
  }

The implementation can leverage internal representation to avoid
branching and thus make the operation cheaper.
2015-04-15 20:33:48 +02:00
Tomasz Grabiec
53eb4ab35d enum_set: Add mask getter 2015-03-11 14:56:09 +01:00
Tomasz Grabiec
13850d912e enum_set: Add more operations 2015-03-11 14:56:09 +01:00
Tomasz Grabiec
29f02b5c65 enum_set: Add more operations 2015-02-16 12:15:11 +01:00
Tomasz Grabiec
16a4b2f3e0 Introduce enum_set
Allows to take full advantage of compile-time information.

Examples:

  enum class x { A, B, C };
  using my_enum = super_enum<x, x::A, x::B, x::C>;
  using my_enumset = enum_set<my_enum>;

  static_assert(my_enumset::frozen<x::A, x::B>::contains<x::A>(),
  		"it should...");

  assert(my_enumset::frozen<x::A, x::B>::contains(x::A));
2015-02-12 19:40:56 +01:00