From Jason Turner
Watch on YouTube

Summary

Jason explores C++11's user-defined literals feature, explaining their constraints and best practices. User-defined literals must accept specific parameter types (unsigned long long, long double, const char*, etc.), must be prefixed with an underscore (non-underscored suffixes are reserved for the standard library), and should almost always be marked consteval to ensure compile-time evaluation. The episode demonstrates creating a kibibyte literal (_KiB) and emphasizes that user-defined literals should return strongly-typed objects rather than built-in types for better type safety.

Resources

Tags