FE 0.6.0
A header-only C++ library for writing 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 |
Public Member Functions | |
constexpr | Sym () noexcept=default |
Getters | |
constexpr bool | empty () const noexcept |
constexpr size_t | size () 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 |
Comparisons | |
constexpr auto | operator<=> (Sym other) const noexcept |
constexpr bool | operator== (Sym other) const noexcept |
constexpr bool | operator!= (Sym other) const noexcept |
constexpr auto | operator<=> (char c) const noexcept |
constexpr auto | operator== (char c) const noexcept |
constexpr auto | operator!= (char c) const noexcept |
Conversions | |
constexpr const char * | c_str () const noexcept |
constexpr | operator const char * () const noexcept |
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 noexcept |
This involves a copy. | |
constexpr | operator std::string () const noexcept |
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 |
std::ostream & | operator<< (std::ostream &o, Sym sym) |
A Symbol just wraps a pointer to Sym::String, so pass Sym itself around as value.
Sym is compatible with:
std::string_view
(via Sym::view)This means that retrieving a std::string_view
or a null-terminated C-string is basically free. You can also obtain a std::string
(via Sym::str), but this involves a copy. 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.
std::string
/std::string_view
, nullptr
, and "\0"
are all identified as Sym::Sym().
|
constexprdefaultnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
Definition at line 132 of file sym.h.
References view().
Referenced by begin(), end(), operator const char *(), and operator[]().
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineexplicitconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineexplicitconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
Definition at line 85 of file sym.h.
References empty(), Short_String_Mask, and size().
Referenced by back(), end(), operator<=>(), operator[](), size(), and view().
|
inlineconstexprnoexcept |
This involves a copy.
Definition at line 148 of file sym.h.
References view().
Referenced by operator std::string().
|
inlineconstexprnoexcept |
Definition at line 135 of file sym.h.
References empty(), Short_String_Mask, and size().
Referenced by c_str(), operator std::string_view(), operator*(), operator<=>(), and str().
|
friend |
|
staticconstexpr |
Definition at line 41 of file sym.h.
Referenced by fe::SymPool::sym().
|
staticconstexpr |