## Problem 7 - Template Meta Programming 2 C++ provides a convenient STL container, ``tuple``. This is an example of using `tuple`. ```c++ auto tuple1 = tuple (5, "qwe", 0.4f); auto tuple2 = make_tuple(1, 4, "qqq"); cout<(tuple1)<(tuple2)<(T& t)`` is a special function template that makes you access to a tuple. Using a **variadic templates**, implement a function that `cout`s all elements in any tuple which has only `cout`-able types. #### Q1 First of all, you'll need a special helper class. ```c++ template struct Ints { /* nothing */ } ``` Implement class templates ``AtoB``, which has ``typedef mytype = ...`` that defines ``Ints`` instantiated with integers ranged A to B. In other words, ```c++ typeid(AtoB<3, 8>::mytype) == typeid(Ints<3,4,5,6,7,8>) ``` This must hold. ##### Hints Use compile-time recursion. Define a base-case specialization. #### Q2 Implement the following three function templates. ```c++ template void print(tuple a); // base case template void print(tuple a); template void temp(Ints not_used, const tuple& t); ``` Here ``temp`` is a helper function that retrieves ``S...`` of some instantiated ``Ints`` in ``print``. You should call ``temp`` from ``print``, and ``temp`` should call the recursive N-1 case of ``print``. ```c++ print(make_tuple(5, "qwe", 3.0f)); >> 5 qwe 3.0 ``` ##### Hints Parameter pack expansion can be used being enclosed with another expression. For example, ```c++ vector a = {S...}; vector b = {abs(S)...}; vector c = {sqrt(abs(S))...}; ``` Consider using that only in the list initialization and the function arguments passing.