Folding in C++ using Variadic Function Template

Written by SoulCollector | Published 2020/04/04
Tech Story Tags: c++ | template | functional-programming | programming | cpp | tutorial | beginners | software-development

TLDR Template parameter pack was introduced in C++11. Today we will use it to write our own fold function. We essentially peel of the first argument from the pack and call the binary function with it and evaluation of fold applied to the remainder of the pack. We can call our fold function in the following manner. When we call fold in main, the general case is selected by the. compiler and it deduces the types for the. argument. This is a sort of the. representation of our tree.via the TL;DR App

no story

Published by HackerNoon on 2020/04/04