|
FE 0.15.0
A C++23 toolkit for writing compiler/interpreter frontends.
|
A Symbol just wraps a pointer to Sym::String, so pass Sym itself around as value. More...
#include <fe/sym.h>
Classes | |
| struct | String |
| struct | Hash |
| struct | Eq |
Public Member Functions | |
| constexpr | Sym () noexcept=default |
Getters | |
| constexpr bool | empty () const noexcept |
| constexpr size_t | size () const noexcept |
| constexpr uintptr_t | raw () const noexcept |
Access | |
| constexpr char | operator[] (size_t i) const noexcept |
| constexpr char | front () const noexcept |
| constexpr char | back () const noexcept |
Iterators | |
| constexpr auto | begin () const noexcept |
| constexpr auto | end () const noexcept |
| constexpr auto | cbegin () const noexcept |
| constexpr auto | cend () const noexcept |
| constexpr auto | rbegin () const noexcept |
| constexpr auto | rend () const noexcept |
| constexpr auto | crbegin () const noexcept |
| constexpr auto | crend () const noexcept |
Conversions | |
| constexpr std::string_view | view () const noexcept |
| constexpr | operator std::string_view () const noexcept |
| constexpr std::string_view | operator* () const noexcept |
| constexpr std::string | str () const |
| This involves a copy. | |
| constexpr | operator std::string () const |
| explicit as this involves a copy. | |
| constexpr | operator bool () const noexcept |
| Is not empty? | |
Static Public Attributes | |
| static constexpr size_t | Short_String_Bytes = sizeof(uintptr_t) |
| static constexpr size_t | Short_String_Mask = Short_String_Bytes - 1 |
Friends | |
| struct | ::std::hash< fe::Sym > |
| class | SymPool |
| template<class H> | |
| constexpr H | AbslHashValue (H h, Sym sym) noexcept |
| std::ostream & | operator<< (std::ostream &os, Sym sym) |
Comparison: Sym w/ Sym | |
| constexpr auto | operator<=> (Sym s1, Sym s2) noexcept |
| constexpr bool | operator== (Sym s1, Sym s2) noexcept |
Comparison: Sym w/ char | |
| constexpr std::strong_ordering | operator<=> (Sym s, char c) noexcept |
| constexpr std::strong_ordering | operator<=> (char c, Sym s) noexcept |
| constexpr bool | operator== (Sym s, char c) noexcept |
| constexpr bool | operator== (char c, Sym s) noexcept |
Comparison: Sym w/ convertible to std::string_view | |
| constexpr auto | operator<=> (Sym lhs, const std::convertible_to< std::string_view > auto &rhs) noexcept |
| constexpr auto | operator<=> (const std::convertible_to< std::string_view > auto &lhs, Sym rhs) noexcept |
| constexpr bool | operator== (Sym lhs, const std::convertible_to< std::string_view > auto &rhs) noexcept |
| constexpr bool | operator== (const std::convertible_to< std::string_view > auto &lhs, Sym rhs) noexcept |
A Symbol just wraps a pointer to Sym::String, so pass Sym itself around as value.
Retrieving a std::string_view (via Sym::view) is basically free. You can also obtain a std::string (via Sym::str), but this involves a copy. The characters are not null-terminated. With the exception of the empty string, you should only create Symbols via SymPool::sym. This in turn will toss all Symbols into a big hash set. This makes Sym::operator== and Sym::operator!= an O(1) operation. The empty string is internally handled as nullptr. Thus, you can create a Symbol representing an empty string without having access to the SymPool.
|
constexprdefaultnoexcept |
Referenced by fe::SymPool::sym().
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlinenodiscardconstexprnoexcept |
Definition at line 83 of file sym.h.
References empty().
Referenced by fe::SymTab< V, Size >::emplace(), empty(), fe::SymTab< V, Size >::find(), size(), and view().
|
inlineconstexprnoexcept |
|
inlineexplicitconstexprnoexcept |
|
inlineexplicitconstexpr |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlinenodiscardconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlinenodiscardconstexprnoexcept |
Definition at line 84 of file sym.h.
References empty(), Short_String_Mask, and size().
Referenced by back(), end(), operator[](), size(), and view().
|
inlineconstexpr |
This involves a copy.
Definition at line 165 of file sym.h.
References view().
Referenced by operator std::string().
|
inlinenodiscardconstexprnoexcept |
Definition at line 151 of file sym.h.
References empty(), Short_String_Mask, and size().
Referenced by begin(), operator std::string_view(), operator*(), operator[](), and str().
|
friend |
Definition at line 171 of file sym.h.
References AbslHashValue.
|
friend |
Definition at line 171 of file sym.h.
Referenced by ::std::hash< fe::Sym >.
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
staticconstexpr |
|
staticconstexpr |