package containers-data

  1. Overview
  2. Docs

Module CCBitFieldSource

Efficient Bit Field for up to 31 or 61 fiels

This module defines efficient bitfields up to 31 or 61 bits (depending on the architecture) in a relatively type-safe way.

  module B = CCBitField.Make(struct end);;

  let x = B.mk_field ()
  let y = B.mk_field ()
  let z = B.mk_field ()

  let f = B.empty |> B.set x true |> B.set y true;;

  assert (not (B.get z f)) ;;

  assert (f |> B.set z true |> B.get z);;
Sourceexception TooManyFields

Raised when too many fields are packed into one bitfield.

Sourceexception Frozen

Raised when a frozen bitfield is modified.

Sourceval max_width : int

System-dependent maximum width for a bitfield, typically 30 or 62.

Sourcemodule type S = sig ... end
Sourcemodule Make () : S

Create a new bitfield type

OCaml

Innovation. Community. Security.