1#ifndef HALCHECK_LIB_ATOM_HPP
2#define HALCHECK_LIB_ATOM_HPP
22#include <halcheck/lib/type_traits.hpp>
23#include <halcheck/lib/variant.hpp>
33namespace halcheck {
namespace lib {
78 template<typename T, HALCHECK_REQUIRE(std::is_constructible<T, const std::string &>())>
79 explicit operator T()
const {
80 return T(_data->
first);
145 explicit operator T()
const {
162 explicit operator T()
const {
194using atom = lib::variant<lib::symbol, lib::number>;
197#if __cplusplus >= 201806L
198template<std::
size_t N>
201 [[nodiscard]]
constexpr size_t size()
const {
return N - 1; }
202 constexpr char_array(
const char (&init)[N]) {
207template<literals::
char_array Value>
212#elif ((__cplusplus >= 201606L || defined(__clang__)) && defined(__GNUG__)) || defined(HALCHECK_DOXYGEN)
213#pragma clang diagnostic push
214#pragma clang diagnostic ignored "-Wgnu-string-literal-operator-template"
220template<
typename T, T... Data>
226#pragma clang diagnostic pop
241struct hash<halcheck::lib::symbol> {
250struct hash<halcheck::lib::number> {
number()=default
Creates a number with zero as its underlying value.
number(value_type value)
Creates a number with the given underlying value.
Definition atom.hpp:127
friend bool operator!=(number lhs, number rhs)
Determines if two numbers are equal.
Definition atom.hpp:185
friend bool operator==(number lhs, number rhs)
Determines if two numbers are equal.
Definition atom.hpp:175
A number is conceptually a signed integer with constant time equality comparison and hashing.
Definition atom.hpp:110
std::int64_t value_type
The underlying integral type.
Definition atom.hpp:115
symbol(const std::string &)
Construct a new symbol from a std::string.
friend bool operator!=(const symbol &lhs, const symbol &rhs)
Determines if two symbols are not equal.
Definition atom.hpp:101
friend bool operator==(const symbol &lhs, const symbol &rhs)
Determines if two symbols are equal.
Definition atom.hpp:92
std::size_t hash() const noexcept
Gets a hash code for this symbol.
Definition atom.hpp:69
symbol(const char *="")
Construct a new symbol from a C string.
A symbol is conceptually a std::string with constant time equality comparison and hashing.
Definition atom.hpp:39
lib::variant< lib::symbol, lib::number > atom
An atom is either a symbol or a number.
Definition atom.hpp:194
HALCHECK_INLINE_CONSTEXPR struct halcheck::lib::@25 size
Obtains the size of a range.
#define HALCHECK_REQUIRE(...)
Expands to a template argument that is only valid if the given argument evaluates to true.
Definition type_traits.hpp:24