EXPLORATION OF C++20 METAPROCRAMMINGtemplates to existing code • Part II: Overload resolution and ADL • Part III: Conditions at compile time pre C++20 • Part IV: Conditions at compile time using C++20 (and beyond…) • Part V: Advanced methods for Error). • We will get an error if we try to call a function with no viable candidates.PART III: CONDITIONS AT COMPILE TIME PRE C++20 18: • type_traits are part of library. • Verified type trait (since C++20): • A constexpr function. • Identifies a situation. 19 PART III: CONDITIONS AT COMPILE TIME PRE C++20 : overview • Classes: • Queries • Helper classes (is constant) 0 码力 | 50 页 | 2.59 MB | 6 月前3
Behavioral Modeling in HW/SW Co-design Using C++ Coroutineslocking mechanisms are designed for shared resources • They don’t handle waiting for combinatorial conditions well • Could use a scoped lock or latch/barrier, but need application of DeMorgan’s theorem mutex … std::scoped_lock joint_lock(lock[1], lock[2]); // Simple enough … // Now let’s lock on 10 conditions std::scoped_lock wide_lock(lock[0], lock[1], lock[2], lock[3], lock[4], lock[5], lock[6], lock[7] Listconditions = {cond0, … , condN}; … // Variatic Argument Approach co_await concurrencpp::when_all(cond0, cond1, cond2); … // Iterator approach co_await concurrencpp::when_all(conditions.begin, conditions 0 码力 | 44 页 | 584.69 KB | 6 月前3
COMPOSABLE C++useful pattern because it allows us to compose structure directly without conditions in the handling code without conditions in the handling code.. We We don't have a dichotomy don't have a dichotomy have don't have to put to put conditions conditions in the calling code. in the calling code.HERE'S THE LEARNING HERE'S THE LEARNING No raw conditions No raw conditions.. A A raw condition raw condition (For the rest of it.) I suggest watching that talk again. (For the rest of it.)NO RAW CONDITIONS NO RAW CONDITIONS Put another way - Put another way - We should strive to put We should strive to put0 码力 | 124 页 | 8.28 MB | 6 月前3
Back to Basics: Debugging Techniquesunder a well-defined set of conditions • In contrast, a non-deterministic defect is a defect that changes its symptoms from run-to-run under a well-defined set of conditions 8CppCon 2021 – Back to Basics: serious error (program termination or C++ exception) if the predicate is false • Verify pre-conditions/post-conditions before/after calling a function • Verify class invariants (e.g., in a self_test() member Delivering the Fix • Create documentation for posterity • How the defect was noticed • The conditions under which the defect occurred – the context • Steps necessary to reproduce the defect – the0 码力 | 44 页 | 470.68 KB | 6 月前3
A Multithreaded, Transaction-Based Locking Strategy for Containersa Container • Sometimes a container must be shared between threads • We desire to avoid race conditions during writes • Assume elements are themselves unsynchronized – i.e., susceptible to races • Containers 3Copyright © 2020 Bob Steagall K E W B C O M P U T I N G Sharing a Container – Avoiding Race Conditions • If all threads are readers… • No locking is required • If the number of reads is much larger Containers 4Copyright © 2020 Bob Steagall K E W B C O M P U T I N G Sharing a Container – Avoiding Race Conditions • What about the case where all operations are writes… -- and -- • Each element E to be updated0 码力 | 142 页 | 474.78 KB | 6 月前3
Design and Implementation of Highly Scalable Quantifiable Data Structures in C++Implementation of Quantifiable Stack/Queue Live Demonstration Overview Motivation Correctness (Safety) Conditions Motivating Examples, Drivers for Change Quantifiability Definition Vector Space System Model Measurement Design and Implementation of Quantifiable Stack/Queue Live Demonstration Correctness Conditions A correctness condition defines correct behavior for a multiprocessor program. ▶ Serializability programmed), while secondary principles such as timing, order and arguments are modifiers on them. "The conditions defined in secondary principles cannot be known without the first, whereas the reverse is not true0 码力 | 51 页 | 4.08 MB | 6 月前3
Scientific Unit Testingbehaviors follow suit, the observable behavior is correct! A bug that cannot be observed under any conditions is not a bug Repeat this to yourself a few times 13Modern Philosophy of Science: Science would 18Basic lab procedure: weighing a sample Zero the scale with the container to duplicate the exact conditions of the experiment. 19Basic lab procedure: weighing a sample Only after calibrating our equipment network latency Y Cue test framework to allow X + Y seconds Adapt test parameters to current test conditions Example: Client must connect to server within X seconds Measure the unwanted environmental effects0 码力 | 45 页 | 1.91 MB | 6 月前3
Vectorizing a CFD Code With std::simd Supplemented by Transparent Loading and StoringCompute( SIMD_UNIVERSAL_ACCESS(point, .GetVelocity(j))); } }); }Extended Features: Handling of Conditions My assumption: time for all vector lanes == time for one vector lane → compute all vector lanes stdx::all_of(mask)) where(!mask, twoF) = MaskedLog(mask, zeta) / f; }Extended Features: Handling of Conditions simd_access::where_expression for reflection support 39 Olaf Krzikalla, DLR SP, 2024-09-17 simd_access::where; where(mask_, d) = s; }); return *this; } };Extended Features: Handling of Conditions 40 Olaf Krzikalla, DLR SP, 2024-09-17 templateT LogMean(const T &val1, const T 0 码力 | 58 页 | 2.68 MB | 6 月前3
Better Code: Contracts• Don't use exceptions for control flow • Only use exceptions for exceptional / unexpected conditions 82© 2023 Adobe. All Rights Reserved. A short rant about (our misunderstanding of) exceptions • Don't use exceptions for control flow • Only use exceptions for exceptional / unexpected conditions The key to power with exceptions is focusing on contracts and invariants, not control flow • • Don't use exceptions for control flow • Only use exceptions for exceptional / unexpected conditions The key to power with exceptions is focusing on contracts and invariants, not control flow •0 码力 | 204 页 | 4.46 MB | 6 月前3
BehaviorTree.CPP: Task Planning for Robots and Virtual AgentsThe leaves of the tree are the Actions. I.e. the user-defined code that should be executed. ● Conditions are Actions that are considered atomic and don’t have side effects. ● Nodes can only return SUCCESS the number associated with RED Pre and Post conditions in Nodes Preconditions: ● skipIf ● successIf ● failureIf ● while Postconditions: ● onSuccess onHalted ● post Scripts executed before the tick() Scripts executed after the tick()Pre and Post conditions in NodesReactive 0 码力 | 59 页 | 7.97 MB | 6 月前3
共 111 条
- 1
- 2
- 3
- 4
- 5
- 6
- 12
相关搜索词
EXPLORATIONOFC++20METAPROCRAMMINGBehavioralModelinginHWSWCodesignUsingCoroutinesCOMPOSABLEBacktoBasicsDebuggingTechniquesMultithreadedTransactionBasedLockingStrategyforContainersDesignandImplementationofHighlyScalableQuantifiableDataStructuresScientificUnitTestingVectorizingCFDCodeWithstdsimdSupplementedbyTransparentLoadingStoringBetterContractsBehaviorTreeCPPTaskPlanningRobotsVirtualAgents













