Home > On-Demand Archives > Workshops >

Modern C++ Interface Design

Ben Saks - Watch Now - EOC 2024 - Duration: 02:00:38

Modern C++ Interface Design
Ben Saks

Prerequisite: Solid knowledge of C, C++ classes, and traditional C enumeration types, as well as a basic understanding of simple C++ templates.

Good interface design is an important part of writing safe, reliable software. By writing interfaces that are easy to use correctly, we let software engineers communicate clearly and reduce maintenance costs. By using the type system to write interfaces that are hard to use incorrectly, we can catch many potential errors at compile time and improve development time.

In this session, we’ll take an existing C++ interface and look at how we can improve on it using Modern C++ features. We’ll see how Modern C++ lets you write enumeration types that avoid common problems and misuses. We’ll discuss new library types and language features that help you write interfaces with more convenient parameter passing and return conventions. We’ll also examine how you can use C++ attributes like [[nodiscard]] to get more feedback from your compiler and catch mistakes earlier in development.

  • scoped enumerations and underlying type specifiers
  • explicit conversion operators
  • attributes (e.g., [[deprecated]], [[nodiscard]], [[fallthrough]], etc.)
  • structured bindings
  • std::optional
  • std::expected
M↓ MARKDOWN HELP
italicssurround text with
*asterisks*
boldsurround text with
**two asterisks**
hyperlink
[hyperlink](https://example.com)
or just a bare URL
code
surround text with
`backticks`
strikethroughsurround text with
~~two tilde characters~~
quote
prefix with
>

jperez
Score: 0 | 2 months ago | 2 replies

Will this be available later?

Stephane.Boucher
Score: 0 | 2 months ago | 1 reply

Yes, the recording will be posted later today.

jperez
Score: 0 | 2 months ago | no reply

thanks

Stephane.Boucher
Score: 1 | 2 months ago | no reply

Available now!

11:11:14 From Caio J. B. V. Guimaraes to Everyone:
	Wouldn't just creating three methods, one for day, another for month and another for year, make it even more clear?
11:11:48 From Caio J. B. V. Guimaraes to Everyone:
	yes, exatcly
11:12:14 From Enrico Gueli to Everyone:
	That looks like "fluent syntax" and Builder pattern used in Java
11:12:59 From Caio J. B. V. Guimaraes to Everyone:
	Replying to "That looks like "flu..."
	
	Indeed.
11:13:04 From Ben Saks to Everyone:
	https://www.saksandassociates.com/EOC/
11:14:32 From Singhal, Rishi to Everyone:
	I tried extracting/opening but a lot of files are password protected
11:14:37 From DanielK to Everyone:
	apologies for the interruption, the zip folder requires a password, not sure if was provided
11:14:46 From Ray Chen to Everyone:
	same here
11:14:47 From DanielK to Everyone:
	Reacted to "I tried extracting/o..." with 👏
11:15:00 From Stephane to Everyone:
	It didn't require a pw for me
11:15:01 From Steven Huff to Everyone:
	Website zip as password protected.
11:15:01 From Jacob Beningo to Everyone:
	It unzipped for me ok
11:15:03 From Ben Saks to Everyone:
	I understood that reference
11:15:05 From Carlos Hidalgo to Everyone:
	The one in the Zoom is NOT password protected
11:15:10 From Eric to Everyone:
	I can open the zip without Problems!
11:15:12 From Jacob Beningo to Everyone:
	Ah perfect
11:15:13 From DanielK to Everyone:
	I understood that reference
11:15:32 From Caio J. B. V. Guimaraes to Everyone:
	great password, btw
11:15:38 From Eric to Everyone:
	Sorry, I was wrong, there is a Password … :(
11:21:03 From Eric to Everyone:
	Integer promotion rules quizz on ER:
11:21:22 From Eric to Everyone:
	https://www.embeddedrelated.com/showquiz/16
11:25:36 From Caio J. B. V. Guimaraes to Everyone:
	that's great! So I could use for uint8_t, uint16_t and uint32_t? Seems obvious, but just asking to make sure...
11:25:54 From Caio J. B. V. Guimaraes to Everyone:
	Great, thanks!
11:26:13 From Nathan to Everyone:
	Specifying underlying types is going to be possible with C23 as well
11:32:57 From Singhal, Rishi to Everyone:
	I think my file already has the solution. It starts with enums not a macro
11:33:13 From Singhal, Rishi to Everyone:
	oh sorry
11:33:17 From Singhal, Rishi to Everyone:
	I misread
11:35:19 From Ben Saks to Everyone:
	You can reach me at ben@saksandassociates.com if you have any questions later on.
11:40:22 From Nathan to Everyone:
	I guess we can't change the type of the dr field in the config structure ?
11:42:01 From Nathan to Everyone:
	oh right, forgot the underlying type at first
12:25:19 From Grunklee, Jacob to Everyone:
	What's the significance of constexpr here?
12:26:56 From Grunklee, Jacob to Everyone:
	Thanks!
12:30:25 From Michael Estes to Everyone:
	Isn't consolidating front() and pop_front() removing the ability to inspect the first element without popping it off the RB?
12:38:26 From Nathan to Everyone:
	Is there any way to declare the function as deprecated but still be able to use it internally (inside for the class) ?
12:48:26 From Ben Saks to Everyone:
	You can reach me at ben@saksandassociates.com if you have any questions later on.
12:56:21 From Nathan to Everyone:
	Here isn't structure binding with a pair with a bool similar to using optional ?
13:00:57 From Michael Estes to Everyone:
	Thank you Ben, this was a great presentation
13:01:07 From Lyden Smith to Everyone:
	Thank you Ben!
13:01:19 From Grunklee, Jacob to Everyone:
	Thanks Ben!
13:01:28 From Ben Saks to Everyone:
	Thanks for coming, everyone!
13:01:32 From Samuel Henrique to Everyone:
	Thank you Ben
13:01:40 From KK to Everyone:
	Thank you Ben

OUR SPONSORS

OUR PARTNERS