Compile-Time Compression and Resource Generation with C++20that take a user-suppiled lambda to generate the data needed to render our desired compile-time resource! These are e�ectively templated functions, but we will use the cleaner auto parameter syntax for0 码力 | 59 页 | 1.86 MB | 6 月前3
The Roles of Symmetry And Orthogonality In DesignOrthogonality In Design cppcon 2021 Symmetry In C++ Code • C++’s most common symmetry example: Resource Management ... { Bar b; //...do stuff with b } Enter the block, object is created Leave the object 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 Orthogonality In Design cppcon 2021 Symmetry In C++ Code • C++’s most common symmetry example: Resource Management ... { Bar b; //...do stuff with b } Enter the block, object is created Leave the0 码力 | 151 页 | 3.20 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 code ? 26 Bloomberg Exceptional DefinitionSituation : Need to explicitly give back / release a resource acquired during an operation before leaving the function / exception block. Exceptions can leave block catches the exception, releases a resource and usually rethrows the exception 27 Bloomberg Exceptional Resource Management30 Bloomberg Exceptional Resource Management int process_file(const std::string&0 码力 | 85 页 | 2.32 MB | 6 月前3
《深入浅出MFC》2/ejjhou@ccca.nctu.edu.tw FAX 886-3-5733976 7 第一版序 有一种软件名曰version control,用来记录程序开发过程中的各种版本,以应不时之需,可以 随时反省、检查、回复过去努力的轨迹。 遗憾的是人的大脑没有version control 的能力。学习过程的彷徨犹豫、挫折困顿、在日积月 累的渐悟或x那之间的顿悟之后,彷佛都成了遥远模糊的回忆;而屡起屡仆、大惑不解的地 再跌倒的地方做上 记号,永志不忘?谁会把推敲再三的心得殷实详尽地记录下来,为后学铺一条红地毯?也许, 没有version control 正是人类的本能,空出更多的脑力心力与精力,追求更新的事物。 但是,作为信息教育体系一员的我,不能不有version control。事实上我亦从来没有忘记初学 MFC 的痛苦:C++ 语言本身的技术问题是其一,MFC 庞大类别库的命名规则是其二,熟知 的Windows 397 Callback 函式 / 398 目 錄 19 * 閒置時間(idle time)的處理:OnIdle / 403 Dialog 與 Control / 406 通用對話盒(Common Controls) / 407 本章回顧 / 409 第7章 簡單而完整:MFC 骨幹程式 / 4110 码力 | 1009 页 | 11.08 MB | 1 年前3
Compile-Time Validationdangling pointers" - WikipediaMemory Safety - Invalidation Invalidation occurs when an object or resource is modified or deallocated, causing references, pointers, or iterators that were pointing to it vec[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 = { /* {1,1} });Control Flow Record and validate control flow enum class control_flow { if_, else_if, for_, return_, /*...*/ }; if (cond) { M::add<control_flow::if_>; } M::add<control_flow::end_scope>;Macro 0 码力 | 137 页 | 1.70 MB | 6 月前3
Back to Basics: Concurrencywho these people are??Good Concurrency = Good Conversation (3/3) Each person is competing for a resource I don’t know who these people are??Does our hardware support Concurrency? Brief Architecture ● One mechanism for achieving concurrency is a ‘thread’ ○ A ‘thread’ allows us to execute two control flows at the same time ○ The ‘main thread’ is where our program starts ■ We may then have 1 or data, and kernel context ○ A thread has its own thread id (TID) ○ A thread has its own logical control flow ○ A thread has its own stack for local variables 40 Figure from: Computer Systems a Programmer's0 码力 | 141 页 | 6.02 MB | 6 月前3
Modern C++ Tutorial: C++11/14/17/20 On the Flydecltype(auto) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 2.4 Control flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 Chapter 02: Language Usability Enhancements When we declare, define a variable or constant, and control the flow of code, object-oriented functions, template programming, etc., before the runtime, it 2.4 Control flow CHAPTER 02: LANGUAGE USABILITY ENHANCEMENTS decltype(auto) look_up_a_string_1() { return lookup1(); } decltype(auto) look_up_a_string_2() { return lookup2(); } 2.4 Control flow0 码力 | 92 页 | 1.79 MB | 1 年前3
Back to Basics: Smart Pointersautomatically manage the lifetime of its resource. ▪ Smart Pointers ▪ Allocate und deallocate their resource in the constructor and destructor according to the RAII idiom (Resource Acquisition Is Initialization) ▪ Release the resource if the smart pointer goes out of scope ▪ Are available in four versions raii.cppOverview Name C++ Standard Description std::auto_ptr C++98 ▪ Owns the resource exclusively ▪ „Moves“ its resource during a copy operation std::unique_ptr C++11 ▪ Owns the resource exclusively ▪ Can not be copied ▪ Deals with non-copy objects std::shared_ptr C++11 ▪ Shares a resource ▪ Supports0 码力 | 30 页 | 625.43 KB | 6 月前3
Interesting Upcoming Features from Low Latency, Parallelism and Concurrency~B() { use_resource_XYZ(); } }; make_resource_XYZ(); { Container container; container.insert(b); container.erase(b); } // Obj containing 'b' may be not deleted yet. destroy_resource_XYZ(); Need ~B() { use_resource_XYZ(); } }; make_resource_XYZ(); { Container container; container.insert(b); container.erase(b); } // Obj containing 'b' must be already deleted. destroy_resource_XYZ(); Synchronous parallel performance. ● ● Execution policies: Parallel range algorithms accept execution policies to control parallelism. ● Random access ranges: Algorithms require random-access ranges for efficient parallelization0 码力 | 56 页 | 514.85 KB | 6 月前3
Bringing Existing Code to CUDA Using constexpr and std::pmrC++17: • std::pmr::memory_resource • std::pmr::polymorphic_allocator • std::pmr::vector • std::pmr::monotonic_buffer_resource • … std::pmr 16 |// gpu unified_memory_resource mem; std::pmr::vectorstd::pmr::vector y(N, &mem); // … Memory Allocation 17 |struct unified_memory_resource : std::pmr::memory_resource { void* do_allocate(std::size_t, std::size_t); void do_deallocate( do_is_equal( const std::pmr::memory_resource& other) const noexcept; }; A Unified Memory Resource 18 |struct unified_memory_resource : std::pmr::memory_resource { void* do_allocate(std::size_t 0 码力 | 51 页 | 3.68 MB | 6 月前3
共 210 条
- 1
- 2
- 3
- 4
- 5
- 6
- 21
相关搜索词
CompileTimeCompressionandResourceGenerationwithC++20TheRolesofSymmetryAndOrthogonalityInDesignExceptionallyBadStoryontheMisuseExceptionsHowtoDoBetter深入深入浅出MFCValidationBackBasicsConcurrencyModernTutorial111417OnFlySmartPointersInterestingUpcomingFeaturesfromLowLatencyParallelismBringingExistingCodeCUDAUsingconstexprstdpmr













