From Jason Turner
Watch on YouTube

Summary

This episode explores function-try-blocks, a rarely used C++ feature that allows wrapping an entire function body in a try-catch block. Jason demonstrates how this syntax works for regular functions but emphasizes its primary practical application in constructors. Function-try-blocks in constructors can catch exceptions thrown during member initialization, providing an opportunity to log or handle initialization failures, though the constructor must still ultimately rethrow an exception as the object cannot be successfully constructed.

Resources

Tags