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.





Your Privacy

By clicking "Accept Non-Essential Cookies" you agree ACCU can store non-essential cookies on your device and disclose information in accordance with our Privacy Policy and Cookie Policy.

Current Setting: Non-Essential Cookies REJECTED


By clicking "Include Third Party Content" you agree ACCU can forward your IP address to third-party sites (such as YouTube) to enhance the information presented on this site, and that third-party sites may store cookies on your device.

Current Setting: Third Party Content EXCLUDED



Settings can be changed at any time from the Cookie Policy page.