Contracts for C++Version 1.0 (pre-Wrocław Edition) Timur Doumler CppCon 18 September 2024 Contracts for C++ The Swan, The Pike, and The Crab – Fable by Ivan Krylov, 18143 Copyright (c) Timur Doumler | Contract"; Eiffel programming language published 2001 D programming language published with Contracts support 2024 We are here12 Copyright (c) Timur Doumler | @timur_audio | https://timur Contract"; Eiffel programming language published 2001 D programming language published with Contracts support 2012 Ada programming language gains Contract support 2024 We are here13 Copyright0 码力 | 181 页 | 4.44 MB | 6 月前3
Better Code: Contracts1Better Code: Contracts Dave Abrahams & Sean Parent What's holding our software together? Can we do better than duct tape and good intentions? 2© 2023 Adobe. All Rights Reserved. Adobe’s Software components whose interaction is based on precisely defined specifications of the mutual obligations — contracts.” —Building bug-free O-O software: An Introduction to Design by Contract™ https://www.eiffel const { return min(size(first()), size(second())); } bool empty() const; ... 60Strong contracts simplify code 61© 2023 Adobe. All Rights Reserved. What's in a “strong contract?” | Tradeoffs0 码力 | 204 页 | 4.46 MB | 6 月前3
Back to Basics: Smart PointersSmart Pointers Back to Basics Rainer Grimm Training, Coaching, and Technology Consulting www.ModernesCpp.netSmart Pointer A First Overview std::unique_ptr – Exclusive Ownership std::shared_ptr – Concurrency Function Arguments and Return ValuesOverview 4 Smart pointers automatically manage the lifetime of its resource. ▪ Smart Pointers ▪ Allocate und deallocate their resource in the constructor management with reference counting ▪ Are C++ answer to garbage collection ▪ Release the resource if the smart pointer goes out of scope ▪ Are available in four versions raii.cppOverview Name C++ Standard0 码力 | 30 页 | 625.43 KB | 6 月前3
Noexcept: Enabling Testing of Contract ChecksGuild of America tell us about software development? • Good programs require good contracts. • Corollary: Good contracts require good enforcement. • Contract checks help catch bugs early in the process noexcept specifier and noexcept operator work and what they are for • The importance of writing contracts and checking them at run time • How to unit test contract-checking annotations (CCAs) • How noexcept replacement: left hip • Lives in Espoo Finland • Member of the C++ Standards Committee; chair of the contracts SG • Co-host of CppCast • Organizer of the Helsinki C++ Meetup • Interests: Clean code, good tools0 码力 | 90 页 | 1.38 MB | 6 月前3
Exceptions Under the SpotlightINBAL LEVIWHO AM I? • AC++ enthusiast. • An embedded software engineer at Solar Edge working on smart home. • One of the organizers of CoreCpp conference and user group. • A Member of WG21. • One of performance reasons. • The error handling mechanism was addressed by C++’s Direction group around 2016 (contracts) and again in 2018. • The exception mechanism was addressed by Herb Sutter (Chair) in 2019: RTTI. PART IV: ALTERNATIVES 45Other suggestions for error handling are on the table as well: 1. Contracts, and pre-conditions. 2. Vicente Botet and JF Bastien’sP0323R9: std::expected. 3. Ben Craig is0 码力 | 53 页 | 2.82 MB | 6 月前3
Regular, Revisitedconstraining types and function prototypes will result in intuitive usage; conversely, breaking subtle contracts for functions and algorithms will result in unexpected behavior for the caller. This talk representation of the elements it references: => we need to have a shallow operator== (just like smart pointers) wg21.link/p1085 Should Span be Regular?2023 Victor Ciura | @ciura_victor - Regular representation of the elements it references: => we need to have a shallow operator== (just like smart pointers) shallow const => shallow operator== wg21.link/p1085 Should Span be Regular?2023 Victor0 码力 | 180 页 | 19.96 MB | 6 月前3
Back To Basics Functionsimplement the function body. ● Functions are also great to use as ‘pre’ and ‘post’ conditions (i.e. contracts) 121Passing lots of parameters to your functions? ● It’s probably best to pass in a ‘struct’ or uct options); ● Another ○ void myFunction(OptionsStruct* options); ○ Pass in as a pointer (or smart pointer) to ensure we’re always just passing in an ‘8-byte’ address (on a 64-bit architecture).0 码力 | 123 页 | 7.26 MB | 6 月前3
Rethinking Task Based Concurrency and Parallelism for Low Latency C++latency market data and trading software for use in HFT ● Personal ○ github.com/buildingcpp ■ Work Contracts, Networking, Messaging, Glimpse Instrumentation, etc … ○ github.com/michaelmaniscalco ■ Algorithms the Alternative?Thread Thread Thread Back Front Work Contracts (Overview): ● A Work Contract Group contains: ○ An array of Work Contracts (each with their own logic and, if needed, data, queue queue, etc) ○ A Signal Tree (which has as many leaf nodes as there are work contracts in the group) ● Threads are brought to the “task” rather than the “task” being brought to the threads (as is done with0 码力 | 142 页 | 2.80 MB | 6 月前3
Constructing Generic AlgorithmsIONS? Let's document them, even if we can't express them in contracts yet. Let's document them, even if we can't express them in contracts yet. 47 . 1PRECONDITIONS/POSTCONDITIONS? PRECONDITIONS/POSTCONDITIONS IONS? Let's document them, even if we can't express them in contracts yet. Let's document them, even if we can't express them in contracts yet. (Pre) [ first, last ) does not contain all possible values IONS? Let's document them, even if we can't express them in contracts yet. Let's document them, even if we can't express them in contracts yet. (Pre) [ first, last ) does not contain all possible values0 码力 | 145 页 | 8.44 MB | 6 月前3
C++26 Previewfixes - always a high priority concurrency support std::execution (P2300) networking reflection, contracts, pattern matching additions to c++20/23 features ranges, format mop up c++23 stuff that missed the 4Outline of the talk I Language & Library debugging structured bindings Language Templates Misc Contracts Reflection 5Outline of the talk II Library: string processing format additions containers ranges 10 11 12 13 26.1Language - Contracts 27Minimum viable product paper Reviewed in Tokyo Provides for preconditions, postconditions, and contract assertions P2900 Contracts for C++ int f(const int x)0 码力 | 118 页 | 2.02 MB | 6 月前3
共 61 条
- 1
- 2
- 3
- 4
- 5
- 6
- 7













