Loading…
CppCon 2019 has ended
Tuesday, September 17 • 15:15 - 15:45
TMI on UDLs: Mechanics, Uses, and Abuses of User-Defined Literals

Log in to save this to your schedule, view media, leave feedback and see who's attending!

We’ve been designing user-defined types in C++ forever, but we were stuck with the same old predefined literal types that somehow had to suit our new concepts. We’d use constructors to beat them into compliance with our new concepts, but we were still just pretending that a double floating-point value had something to do with a kilogram.

C++11 introduced user-defined literals, and C++14, C++17, and C++20 have extended their convenience. In this brisk talk, we’ll look at the mechanics of all six varieties of user-defined literals and use them in a straightforward way to enhance usability and correctness of our user-defined types, and banish type sinks from our interfaces. Along the way, we'll see what the standard lets us get away with and what it doesn't.

Then we’ll see how to force people to write their integers in base 5, require that literals adhere to a particular syntax, deal with those pesky 256-bit integers, and circumvent problems with octals. Time permitting, we’ll see some unusual and possibly useful things we can do with user-defined literals.

Speakers
avatar for Stephen Dewhurst

Stephen Dewhurst

President, Semantics Consulting, Inc.
Steve Dewhurst is the co-founder and president of Semantics Consulting, Inc. Steve is the author of numerous technical articles on C++ programming techniques and compiler design, is the author of the critically acclaimed books C++ Common Knowledge and C++ Gotchas, and is the co-author... Read More →


Tuesday September 17, 2019 15:15 - 15:45 MDT
Crest 3