The Point Challenge - Returning Different Types for the Same Operation

By Amir Kirsh

Types are important as a tool for enforcing program correctness. In this session we would discuss types, specifically - Point.

There is no real logic in adding up two points (result is meaningless) - so we probably may not implement operator+ for Point…​ Unless we want to calculate an average location, then summing 2 points and dividing by two should be supported, preferably treating the result as a real Point only after the division by 2. We would discuss this problem and see how we can implement methods that return different types for (almost) the same operation and enforcing compile time type correctness.

Discussion would go through actual code and usage of cool C++ features such as if constexpr, advnaced template techniques and more.