IDragnev / Algebraic-data-types

Implementation of C++ variant and tuple with additional algorithms and pipe syntax for tuples.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Tuple and Variant

Implementation of fully-featured C++17 variant and tuple with additional algorithms for tuple, such as:

  • insertBack
  • insertFront
  • select
  • reverse
  • take
  • drop
  • sortByType
  • replicate
  • apply
  • foldl
  • transform
  • forEach
  • concatenate
    and more.

Tuples also support the pipe syntax:

  const auto sum = [](const auto& tuple) { return foldl(tuple, 0, std::plus{}); };
  const auto s = makeTuple(1, 2, 3, 4, 5)
                 | take<3>
                 | sum;
  //s == 6

Examples and details can be found in the tests of tuple and tests of variant.
Structured bindings are not supported due to some ambiguity in the get function.

About

Implementation of C++ variant and tuple with additional algorithms and pipe syntax for tuples.

License:MIT License


Languages

Language:C++ 100.0%