Compile-Time Validationvec[index] = 0; // valid vec.clear(); vec[index] = 2; // invalid }Goals – Control Flow Validate based of control flow for: if/else, for loops, etc... void foo() { my_vectorvec = { /* ... */ });Control Flow Record and validate control flow enum class control_flow { if_, else_if, for_, return_, /*...*/ }; if (cond) { M::add flow::if_>; } M::add flow::end_scope>;Macro }));Control Flow - Parsing Parse string of code into a control flow enum value constexpr control_flow parse_control(std::string_view str) { if (str == "{") return control_flow::start_scope; 0 码力 | 137 页 | 1.70 MB | 6 月前3
The Roles of Symmetry And Orthogonality In Designis destroyed Stack-based (automatic) data objects • Is symmetry to define state based on control-flow (static lexical scoping) • Edge cases managed by the C++ Standard (Guaranteed!) “The compiler giveth is destroyed Stack-based (automatic) data objects • Is symmetry to define state based on control-flow (static lexical scoping) • Edge cases managed by the C++ Standard (Guaranteed!) “The compiler giveth taketh away” Heap-based (dynamic) data objects • Is symmetry to define state independent of control-flow (static lexical scoping) • Edge cases managed by the developer “The developer giveth, and the developer0 码力 | 151 页 | 3.20 MB | 6 月前3
Code Analysis++● Lifetime safety ● Data Flow Analysis● DFA analyzes the data: ● Function parameters/ arguments ● Function return value ● Fields and global variables Data Flow Analysis – Condition is always }Data Flow Analysis – void linked_list::process() { for (node *pt = head; pt != nullptr; pt = pt->next) { delete pt; } } Local variable may point to deallocated memoryData Flow Analysis recursion ● Unused values ● Null dereference ● Escape analysis ● Dangling pointers Data Flow Analysis – class Deref { int* foo() { return nullptr; } public: void bar()0 码力 | 61 页 | 2.70 MB | 6 月前3
Exceptionally Bad: The Story on the Misuse of Exceptions and How to Do BetterExceptions were designed for ? • Program has encountered a serious error, and getting out of this control flow to prevent data corruption or other damage is more important than trying to continue onward. • handling if the event doesn't occur often, that is, if the event is truly exceptional How much of your flow (upper-bound) should be taking exception paths ? • Does anyone measure this ? How do I handle “frequent” functionality (as opposed to logging and reset) 66 Bloomberg Exceptional Control Flow68 Bloomberg Exceptional Control Flow bool process(const Info& data) { try { Msg request = apply(data); return send(request);0 码力 | 85 页 | 2.32 MB | 6 月前3
Using Modern C++ to Build XOffsetDatastructurewrite • The diagram illustrates that, just like a road without bottlenecks allows for smooth traffic flow, we need to ensures that all operations run efficiently. Fanchen Su, XOffsetDatastructure, CppCon Encoding and Zero Decoding • As illustrated in the diagram, our solution enables free and efficient flow of data through all stages: reading, writing, sending and receiving data. • The ability to freely XOffsetDatastructure, CppCon 2024 61 Send & Recv Send & Recv Read & Write Read & Write Read & Write Data Flow4. Performance Statistics The performance statistics of XOffsetDatastructure are presented in this0 码力 | 111 页 | 3.03 MB | 6 月前3
Conan 1.18 Documentation. . . . . . . . . . . . . . . . . . . . . . 67 7 Developing packages 73 7.1 Package development flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 7.2 Packages in testing the package locally before upload. As we don’t want to build the package from the sources, the flow would be: $ conan new Hello/0.1 --bare --test # customize test_package project # customize package Creation Process It is very useful for package creators and Conan users in general to understand the flow for creating a package inside the conan local cache, and all about its layout. Each package recipe0 码力 | 584 页 | 4.80 MB | 1 年前3
Conan 1.19 Documentation. . . . . . . . . . . . . . . . . . . . . . 69 7 Developing packages 75 7.1 Package development flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 7.2 Packages in testing the package locally before upload. As we don’t want to build the package from the sources, the flow would be: $ conan new Hello/0.1 --bare --test # customize test_package project # customize package Creation Process It is very useful for package creators and Conan users in general to understand the flow for creating a package inside the conan local cache, and all about its layout. Each package recipe0 码力 | 609 页 | 4.88 MB | 1 年前3
Conan 1.20 Documentation. . . . . . . . . . . . . . . . . . . . . . 69 7 Developing packages 75 7.1 Package development flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 7.2 Packages in testing the package locally before upload. As we don’t want to build the package from the sources, the flow would be: $ conan new Hello/0.1 --bare --test # customize test_package project # customize package Creation Process It is very useful for package creators and Conan users in general to understand the flow for creating a package inside the conan local cache, and all about its layout. Each package recipe0 码力 | 611 页 | 4.89 MB | 1 年前3
Conan 1.16 Documentation. . . . . . . . . . . . . . . . . . . . . . 68 7 Developing packages 75 7.1 Package development flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 7.2 Packages in testing the package locally before upload. As we don’t want to build the package from the sources, the flow would be: $ conan new Hello/0.1 --bare --test # customize test_package project # customize package Creation Process It is very useful for package creators and Conan users in general to understand the flow for creating a package inside the conan local cache, and all about its layout. Each package recipe0 码力 | 545 页 | 4.34 MB | 1 年前3
Conan 1.15 Documentation. . . . . . . . . . . . . . . . . . . . . . 70 7 Developing packages 77 7.1 Package development flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 7.2 Packages in testing the package locally before upload. As we don’t want to build the package from the sources, the flow would be: $ conan new Hello/0.1 --bare --test # customize test_package project # customize package Creation Process It is very useful for package creators and Conan users in general to understand the flow for creating a package inside the conan local cache, and all about its layout. Each package recipe0 码力 | 540 页 | 4.22 MB | 1 年前3
共 111 条
- 1
- 2
- 3
- 4
- 5
- 6
- 12













