This is an example of how to use the classify() function to write FizzBuzz numbers.
#include <array>
#include <exptl/algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <ranges>
#include <string>
int main()
{
std::array<std::function<bool(int)>, 2> funcs{
[](int v) { return !(v % 3); }, [](int v) { return !(v % 5); }};
std::map<decltype(funcs)::const_iterator, std::string> words{
{funcs.cbegin(), "Fizz"}, {funcs.cbegin() + 1, "Buzz"}};
for (auto value : std::views::iota(1, 21))
{
if (result.size())
for (auto const &it : result)
std::cout << words[it];
else
std::cout << value;
std::cout << std::endl;
}
}
constexpr classify(T const value, In &&range)
Checks a value against a range of predicates and returns a vector of iterators to the satisfied predi...
Definition: algorithm.hpp:101