kumi v3.1.0
Exquisite Epidote
Loading...
Searching...
No Matches
kumi::identifier< ID, Checker > Struct Template Reference

identifier definition class More...

#include <kumi/utils/identifier.hpp>

Detailed Description

template<typename ID, typename Checker>
struct kumi::identifier< ID, Checker >

identifier definition class

kumi::identifier defines a identifier, i.e an entity that can receive values and can be stored as part of a product type. It is defined by a unique type ID which can be an actual type or generated from kumi::name and an optional checking operations that will validate the value passed to the identifier is acceptable.

kumi::identifier can also be used to define custom identifier type with specific behavior.

Template Parameters
IDidentifier type being defined
CheckerPotential type checker meta-function. By default, this is void to notify no check is performed.
#include <kumi/kumi.hpp>
#include <iostream>
#include <string>
using namespace kumi::literals;
inline constexpr auto name = kumi::identifier("name"_id);
int main()
{
std::cout << kumi::record{ name = std::string{"Jane Doe"} } << "\n";
}
identifier definition class
Definition identifier.hpp:78
Compile-time text based ID.
Definition identifier.hpp:147
Fixed-size collection of heterogeneous fields necessarily named, names are unique.
Definition record.hpp:29

Public Types

using tag_type = identifier<ID, Checker>
 Derived identifier type.

Public Member Functions

constexpr identifier () noexcept
 Default constructor.
constexpr identifier (ID const &id, Checker const &chk) noexcept
 Constructs a identifier from an ID and a checker type.
template<typename T>
constexpr field< tag_type, std::unwrap_ref_decay_t< T > > operator= (T &&v) const noexcept
 Assignment of a value to a identifier.

Friends

constexpr str to_str (identifier< ID, Checker > const &)
 A checked field str representation is the underlying type, checker is ignored.

(Note that these are not member symbols.)

template<typename CharT, typename Traits>
std::basic_ostream< CharT, Traits > & operator<< (std::basic_ostream< CharT, Traits > &os, identifier const &id) noexcept
 Output stream insertion.