C++ language Flashcards
C++: compile time type conversion
static_cast
C++: down casting
dynamic_cast
C++: modify the const or volatile qualifier of a variable
const_cast
C++: converting a pointer to any other type of pointer
reinterpret_cast
Which memory order has no ordering constraints on other reads or writes?
Relaxed
Consumer memory order Constraints on consumer and release threads
Consumer: No read or writes dependent on the atomic value can be reordered before the load
Releaser: Writes to other data dependent variables are visible in the consumer thread
Constraints on current and other threads for the acquire memory order
No reads or writes in the current thread can be reordered before this load
All writes in other threads that release this atomic variable are visible in the current thread
Constraints of release memory order on current thread, an acquiring thread and a consuming thread
Current: No reads or writes can be reordered after the store
Acquirer: all previous writes from the releasing thread are visible to the acquiring thread
Consumer: previous writes that carry a dependency into the atomic variable from the releasing thread are visible to the consuming thread
Three reasons why volatile cannot replace atomic access
May reorder past side effects as observed by another thread
May reorder other non volatile memory accesses
Not concurrent
Four ways to pass an object to a function, and how it impacts the object ownership
Copy: Both
Reference: caller
Rvalue reference: callee
Forward reference: normal or rvalue reference
Std::visit
Apply different functions to a variant object based on its current type
C++ RVO: d2
Return value optimization
Eliminate unnecessary copy for returned object
C++: pImpl Idiom - what, 2 benefits
Move private details into a separate structure
Compile time firewall
ABI stability
Forward declaration: why, 4 uses, 2 not
Reduce compile time dependencies
Base classes, Member actual types
Pointer, reference, function parameter, function return
Dependency injection: what
Technique in which an object or a function receives other objects and functions it needs, instead of creating them internally