top of page

AmonSTD

Technologies Used:

  • C++

  • Visual Studio

GitHub Page:

Solo Project

Template Metaprogramming practice project

What have been done:

  • ​Implemented my own Tuple, recursive method

  • Basic Tuple operations like comparison and output.

  • Some tuple algorithms like, Adding: Pushback, Pushfront, and popfront

What are the next steps:

  • More algorithms can be added like, Sorting and Reversing

  • More Templates and designs can be added like Typelists. 

  • Can use optimization methods like empty base class optimization(EBCO)

Details:

        The main idea behind this project to get accustomed to template Metaprogramming, and create my own implementations for them.

        Tuples aggregate data in a matter similar to classes and structs. For example tuple containing int and a string is similar to a struct with int and a string, except that the elements of a tuple are referenced positionally, rather than through the names. 

        Tuples contain storage for each of the types in the template argument list. That storage can be accessed through a function template get.  This is a simple recursive implementation of the tuple

        Tuple algorithms require both runtime and compile time computation. Applying an algorithm to a tuple may result in a tuple with completely different type, which requires compile time computation. However tuple algorithms actually require code to execute at runtime so we need to be mindful of the efficiency of the generated code.

​

        As of now for simplicity, I ignored the actual run time component of the tuple template, this will be worked later on.

        The ability to add an element to the beginning or end of a tuple is important for building more advanced algorithms.  Insertion at the front of a tuple is easy. Adding a new element in front of an existing tuple require us to form a new tuple with the new value as the head and the existing tuple as the rest.

        Adding a new element to the end of an existing tuple is more complicated because it requires a recursive walk of the tuple, building up the modified tuple as we go. The basis case appends a value to a zero length tuple by producing a tuple containing just that value. In the recursive case we form  a new tuple from the current element of at the beginning of the list and the result of adding the new element to the rest of the list.

        Also Popfront, as shown in above, is also easy to implement

bottom of page