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?
c++
Relaxed
Consumer memory order Constraints on consumer and release threads
C++
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
C++
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 on release memory order on a releasing thread, an acquiring thread, and a consuming thread
C++
Releaser: 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
C++
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
C++
Copy: Both
Reference: caller
Rvalue reference: callee
Forward reference: normal or rvalue reference
Std::visit
C++
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
C++
Reduce compile time dependencies
Base classes, Member actual types
Pointer, reference, function parameter, function return
Dependency injection: what
Programming
Technique in which an object or a function receives other objects and functions it needs, instead of creating them internally
Dependency inversion pattern
Programming
Both higher and lower layers use abstractions to increase reuseability of higher layers
Four execution policies
C++algorithm
Sequenced, un sequenced, parallel, parallel unsequenced
C++ algorithm for taking elements from one container to creating elements in another container
STD::transform
What is an insert iterator
C++
Calls the containerβs insert method when assigned to
C++ algorithm for filtering out elements from a range but donβt care about the order of the remaining elements
STD remove_if
purpose, preserve
STD partition
C++ algorithm for dividing elements into two groups based on a condition and preserving the relative order within each group
STD set_difference: what, how
Find differences between two sorted ranges
Copy elements from first range not in second range to output range
4 meanings of f(x) in c++
Function call to f
A cast to type f
A function type
A declaration of x
Std iota
C++
Fill a range with sequentially increasing value
aggregated struct: 4 criteria
C++
No user defined constructors
No private or protected non static data members
No base classes
No virtual functions
Three benefits to pass by value
Eliminate pointer indirection by callee
Eliminate a spill in the caller
Eliminate aliasing