template<typename... Ts>
class kumi::record< Ts >
Fixed-size collection of heterogeneous fields with distinct labels.
kumi::record provides an aggregate based implementation of a record. It provides algorithms and functions designed to facilitate record's handling and transformations.
kumi::record is also compatible with standard tuple operations and structured bindings to some extent.
- Template Parameters
-
- See also
- Record Type
Example:
#include <iostream>
#include <stdexcept>
#include <string>
#include <kumi/kumi.hpp>
using namespace kumi::literals;
auto get_student(int id)
{
switch (id)
{
case 0:
return kumi::record{
"GPA"_id = 3.8,
"grade"_id =
'A',
"name"_id = std::string{
"Lisa Simpson"}};
case 1:
return kumi::record{
"GPA"_id = 2.9,
"grade"_id =
'C',
"name"_id = std::string{
"Milhouse Van Houten"}};
case 2:
return kumi::record{
"GPA"_id = 1.7,
"grade"_id =
'D',
"name"_id = std::string{
"Ralph Wiggum"}};
case 3:
return kumi::record{
"GPA"_id = 0.6,
"grade"_id =
'F',
"name"_id = std::string{
"Bart Simpson"}};
}
throw std::invalid_argument("id");
}
int main()
{
const auto student0 = get_student(0);
std::cout << "ID: 0, "
<<
"GPA: " <<
kumi::get<
"GPA">(student0) <<
", "
<<
"name: " <<
kumi::get<
"name">(student0) <<
'\n';
const auto student1 = get_student(1);
std::cout << "ID: 1, "
double gpa2;
char grade2;
std::string name2;
std::cout << "ID: 2, "
<< "GPA: " << gpa2 << ", "
<< "grade: " << grade2 << ", "
<< "name: " << name2 << '\n';
const auto [gpa3, grade3, name3] = get_student(3);
std::cout << "ID: 3, "
<< gpa3 << ", "
<< grade3 << ", "
<< name3 << '\n';
}
decltype(auto) constexpr get(array< T, N > &t) noexcept
Extracts the Ith element from a kumi::array.
Definition array.hpp:672
Fixed-size collection of heterogeneous fields with distinct labels.
Definition record.hpp:36
|
template<typename... Us>
requires ( kumi::concepts::equivalent<record, record<Us...>> && (std::is_assignable_v<typename Ts::type&, std::remove_reference_t<kumi::field_of_t<Ts, record<Us...>>>&&> && ...)) |
| constexpr record & | operator= (record< Us... > &&other) noexcept((std::is_nothrow_assignable_v< typename Ts::type &, std::remove_reference_t< kumi::field_of_t< Ts, record< Us... > > > && > &&...)) |
| | This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
template<typename... Us>
requires ( kumi::concepts::equivalent<record, record<Us...>> && (std::is_assignable_v<typename Ts::type&, std::remove_reference_t<kumi::field_of_t<Ts, record<Us...>>> const&> && ...)) |
| constexpr record & | operator= (record< Us... > const &other) noexcept((std::is_nothrow_assignable_v< typename Ts::type &, std::remove_reference_t< kumi::field_of_t< Ts, record< Us... > > > const & > &&...)) |
| | Replaces the content of the record with the content of another record.
|
template<std::size_t I>
requires (I < sizeof...(Ts)) |
| constexpr decltype(auto) | operator[] (kumi::index_t< I > i) &noexcept |
| | Extracts the Ith field from a kumi::record.
|
template<std::size_t I>
requires (I < sizeof...(Ts)) |
| constexpr decltype(auto) | operator[] (kumi::index_t< I >) &&noexcept |
| | This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
template<std::size_t I>
requires (I < sizeof...(Ts)) |
| constexpr decltype(auto) | operator[] (kumi::index_t< I >) const &&noexcept |
| | This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
template<std::size_t I>
requires (I < sizeof...(Ts)) |
| constexpr decltype(auto) | operator[] (kumi::index_t< I >) const &noexcept |
| | This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
template<typename T>
requires (kumi::concepts::uniquely_typed<kumi_implementation_defined...> && kumi::concepts::contains_type<T, kumi_implementation_defined...>) |
| constexpr decltype(auto) | operator[] (kumi::as< T > type) &noexcept |
| | Extracts the element with type T from a kumi::record.
|
template<typename T>
requires (kumi::concepts::uniquely_typed<kumi_implementation_defined...> && kumi::concepts::contains_type<T, kumi_implementation_defined...>) |
| constexpr decltype(auto) | operator[] (kumi::as< T >) &&noexcept |
| | This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
template<typename T>
requires (kumi::concepts::uniquely_typed<kumi_implementation_defined...> && kumi::concepts::contains_type<T, kumi_implementation_defined...>) |
| constexpr decltype(auto) | operator[] (kumi::as< T >) const &&noexcept |
| | This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
template<typename T>
requires (kumi::concepts::uniquely_typed<kumi_implementation_defined...> && kumi::concepts::contains_type<T, kumi_implementation_defined...>) |
| constexpr decltype(auto) | operator[] (kumi::as< T >) const &noexcept |
| | This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
template<kumi::str Name>
requires (kumi::concepts::contains_label<kumi::label_t<Name>, Ts...>) |
| constexpr decltype(auto) | operator[] (kumi::label_t< Name > l) &noexcept |
| | Extracts the element of the field labeled L from a kumi::record.
|
template<kumi::str Name>
requires (kumi::concepts::contains_label<kumi::label_t<Name>, Ts...>) |
| constexpr decltype(auto) | operator[] (kumi::label_t< Name >) &&noexcept |
| | This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
template<kumi::str Name>
requires (kumi::concepts::contains_label<kumi::label_t<Name>, Ts...>) |
| constexpr decltype(auto) | operator[] (kumi::label_t< Name >) const &&noexcept |
| | This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
template<kumi::str Name>
requires (kumi::concepts::contains_label<kumi::label_t<Name>, Ts...>) |
| constexpr decltype(auto) | operator[] (kumi::label_t< Name >) const &noexcept |
| | This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
template<kumi::concepts::identifier Id>
requires (kumi::concepts::contains_identifier<Id, Ts...>) |
| constexpr decltype(auto) | operator[] (Id const &) &noexcept |
| | Extracts the element whose identifier matches Id from a kumi::record.
|
template<kumi::concepts::identifier Id>
requires (kumi::concepts::contains_identifier<Id, Ts...>) |
| constexpr decltype(auto) | operator[] (Id const &) &&noexcept |
| | This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
template<kumi::concepts::identifier Id>
requires (kumi::concepts::contains_identifier<Id, Ts...>) |
| constexpr decltype(auto) | operator[] (Id const &) const &&noexcept |
| | This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
template<kumi::concepts::identifier Id>
requires (kumi::concepts::contains_identifier<Id, Ts...>) |
| constexpr decltype(auto) | operator[] (Id const &) const &noexcept |
| | This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
|
(Note that these are not member symbols.)
|
|
template<typename CharT, typename Traits, typename... Ts> |
| std::basic_ostream< CharT, Traits > & | operator<< (std::basic_ostream< CharT, Traits > &os, record< Ts... > const &t) noexcept |
| | Inserts a kumi::record in an output stream.
|
|
template<typename... Ts, typename... Us> |
| constexpr auto | operator== (record< Ts... > const &self, record< Us... > const &other) noexcept |
| | Compares a record with another for equality.
|
|
template<typename... Ts, typename... Us> |
| constexpr auto | operator!= (record< Ts... > const &self, record< Us... > const &other) noexcept |
| | Compares a record with another for inequality.
|
| template<typename... Ts> |
| | record (Ts &&...) -> record< std::unwrap_ref_decay_t< Ts >... > |
| | kumi::record deduction guide
|
| template<std::size_t I, typename... Ts> |
| decltype(auto) constexpr | get (record< Ts... > &r) noexcept |
| | Extracts the Ith field from a kumi::record.
|
| template<std::size_t I, typename... Ts> |
| decltype(auto) constexpr | get (record< Ts... > &&r) noexcept |
| template<std::size_t I, typename... Ts> |
| decltype(auto) constexpr | get (record< Ts... > const &r) noexcept |
| template<std::size_t I, typename... Ts> |
| decltype(auto) constexpr | get (record< Ts... > const &&r) noexcept |
| template<kumi::str L, typename... Ts> |
| decltype(auto) constexpr | get (record< Ts... > &r) noexcept |
| | Extracts the element of the field labeled L from a kumi::record if it exists.
|
| template<kumi::str L, typename... Ts> |
| decltype(auto) constexpr | get (record< Ts... > &&r) noexcept |
| template<kumi::str L, typename... Ts> |
| decltype(auto) constexpr | get (record< Ts... > const &r) noexcept |
| template<kumi::str L, typename... Ts> |
| decltype(auto) constexpr | get (record< Ts... > const &&r) noexcept |
| template<kumi::concepts::identifier auto Id, typename... Ts> |
| decltype(auto) constexpr | get (record< Ts... > &r) noexcept |
| | Extracts the element of the field identified by Id from a kumi::record if it exists.
|
| template<kumi::concepts::identifier auto Id, typename... Ts> |
| decltype(auto) constexpr | get (record< Ts... > &&r) noexcept |
| template<kumi::concepts::identifier auto Id, typename... Ts> |
| decltype(auto) constexpr | get (record< Ts... > const &r) noexcept |
| template<kumi::concepts::identifier auto Id, typename... Ts> |
| decltype(auto) constexpr | get (record< Ts... > const &&r) noexcept |
| template<typename T, typename... Ts> |
| decltype(auto) constexpr | get (record< Ts... > &r) noexcept |
| | Extracts the element of the field whose underlying type is T from a kumi::record if it exists.
|
| template<typename T, typename... Ts> |
| decltype(auto) constexpr | get (record< Ts... > &&r) noexcept |
| template<typename T, typename... Ts> |
| decltype(auto) constexpr | get (record< Ts... > const &r) noexcept |
| template<typename T, typename... Ts> |
| decltype(auto) constexpr | get (record< Ts... > const &&r) noexcept |