Skip to content

Latest commit

 

History

History
43 lines (34 loc) · 1.25 KB

Product.md

File metadata and controls

43 lines (34 loc) · 1.25 KB

<CppML/Functional/Product.hpp>

Product

template <typename ...Fs, typename Pipe>
struct Product {
  template <typename ...Ts>
  using f = /* .... */;
};

Product<Fs..., Pipe>

Product<Fs..., Pipe> is a metafunction that passes to Pipe the parameter pack Us..., which is generated by invoking each F in the parameter pack Fs... on the entire parameter pack Ts....

f:: Ts... -> Fs(Ts...)... >-> Pipe

Args...

The parameter pack of the Product<Args...> will be treated as Pipe, and must always be provided (there is no default).

Example

The ml::Partition can be implemented a Product of ml::Filter and ml::RemoveIf, that Pipes to ml::ToList.

template <typename Predicate>
using Partition = ml::Product<
                      ml::Filter<Predicate>,
                      ml::RemoveIf<Predicate>,
                      ml::ToList>;
using T = ml::f<
              Partition<ml::IsClass<>>,
              int, std::string, char>;
static_assert(
      std::is_same_v<
            T,
            ml::ListT<
                ml::ListT<std::string>,
                ml::ListT<int, char>>>);