|
FE 0.15.0
A C++23 toolkit for writing compiler/interpreter frontends.
|
A fixed-capacity Symbol -> V map for a closed set of Size entries: filled once, then only looked up - a Lexer's reserved words, say.
More...
#include <fe/sym.h>
Public Member Functions | |
Access | |
| void | emplace (Sym sym, V v) |
| std::optional< V > | find (Sym sym) const |
Yields nothing if sym is not present - the empty Symbol never is. | |
| bool | contains (Sym sym) const |
Static Public Attributes | |
| static constexpr size_t | Capacity = std::bit_ceil(2 * Size) |
Twice Size, rounded up to a power of two, so the load factor stays below 1/2. | |
A fixed-capacity Symbol -> V map for a closed set of Size entries: filled once, then only looked up - a Lexer's reserved words, say.
Prefer this over SymMap for that use: both hash and compare the same interned pointer, but SymMap pays a full finalizer and a SwissTable group probe where this pays one multiply and one probe of a table whose capacity is a compile-time constant.
V has to be default-constructible; an absent key yields no V at all - see SymTab::find.
|
inline |
|
inline |
Definition at line 260 of file sym.h.
References fe::Sym::empty().
|
inline |
Yields nothing if sym is not present - the empty Symbol never is.
Definition at line 273 of file sym.h.
References fe::Sym::empty().
Referenced by contains().
|
staticconstexpr |