KUMI is a fancy C++20 implementation of a tuple-like class. It tries to be as close to std::tuple as possible but also wants to compile faster, uses a better C++20 oriented interface, and new features like:
- A fast to compile tuple implementation
- Quality of life improvement over the standard tuple implementation
- A protocol to adapt user-defined type to act as tuples
- Algorithm on tuples
- Record type handling
Examples
Tuple
#include <iostream>
#include <kumi/kumi.hpp>
auto get_student(int id)
{
}
int main()
{
auto student0 = get_student(0);
std::cout << "ID: 0, "
auto [ gpa1, grade1, name1 ] = get_student(1);
std::cout << "ID: 1, "
<< "GPA: " << gpa1 << ", "
<< "grade: " << grade1 << ", "
<< "name: " << name1 << '\n';
std::cout << "\n";
auto all_students =
kumi::make_tuple(get_student(0),get_student(1),get_student(2));
std::cout << "Data #" << i << " : " << m << "\n";
}
, all_students
);
std::cout << "\n";
std::cout << grades << "\n";
}
constexpr for_each_index_t for_each_index
Definition for_each.hpp:189
constexpr make_tuple_t make_tuple
Definition tuple.hpp:655
constexpr transpose_t transpose
Definition transpose.hpp:103
decltype(auto) constexpr get(array< T, N > &t) noexcept
Extracts the Ith element from a kumi::array.
Definition array.hpp:672
Record
#include <iostream>
#include <kumi/kumi.hpp>
using namespace kumi::literals;
auto get_student(int id)
{
}
int main()
{
auto student0 = get_student(0);
std::cout << "ID: 0, "
<<
"GPA: " <<
kumi::get<
"GPA">(student0) <<
", "
auto [ gpa1, grade1 ] = get_student(1);
std::cout << "ID: 1, "
<< gpa1 << ", "
<< grade1 << '\n';
std::cout << "\n";
"Lisa Simpson"_id = get_student(0),
"Milhouse Van Houten"_id = get_student(1),
"Ralph Wiggum"_id = get_student(2)
);
std::cout <<
"Student: " <<
name <<
", Data : " << m <<
"\n";
}
, all_students
);
std::cout << "\n";
}
constexpr for_each_field_t for_each_field
Definition for_each.hpp:241
constexpr make_record_t make_record
Definition record.hpp:620
Compile-time text based identifier.
Definition identifier.hpp:165
Licence
This library is licensed under the Boost Software License. The full license text is available on the Licence page.