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 | |
Sym () noexcept=default | |
Getters | |
bool | empty () const |
size_t | size () const |
Access | |
char | operator[] (size_t i) const |
char | front () const |
char | back () const |
Iterators | |
auto | begin () const |
auto | end () const |
auto | cbegin () const |
auto | cend () const |
auto | rbegin () const |
auto | rend () const |
auto | crbegin () const |
auto | crend () const |
Comparisons | |
auto | operator<=> (Sym other) const |
bool | operator== (Sym other) const |
bool | operator!= (Sym other) const |
auto | operator<=> (char c) const |
auto | operator== (char c) const |
auto | operator!= (char c) const |
Conversions | |
const char * | c_str () const |
operator const char * () const | |
std::string_view | view () const |
operator std::string_view () const | |
std::string_view | operator* () const |
std::string | str () const |
This involves a copy. | |
operator std::string () const | |
explicit as this involves a copy. | |
operator bool () const | |
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().
|
defaultnoexcept |
|
inline |
|
inline |
Definition at line 132 of file sym.h.
References view().
Referenced by begin(), end(), operator const char *(), and operator[]().
|
inline |
|
inline |
|
inline |
|
inlineexplicit |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Definition at line 85 of file sym.h.
References empty(), Short_String_Mask, and size().
Referenced by back(), end(), operator<=>(), operator[](), size(), and view().
|
inline |
This involves a copy.
Definition at line 148 of file sym.h.
References view().
Referenced by operator std::string().
|
inline |
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 |