C++ language Flashcards

1
Q

C++: compile time type conversion

A

static_cast

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

C++: down casting

A

dynamic_cast

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

C++: modify the const or volatile qualifier of a variable

A

const_cast

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

C++: converting a pointer to any other type of pointer

A

reinterpret_cast

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Which memory order has no ordering constraints on other reads or writes?

A

Relaxed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Consumer memory order Constraints on consumer and release threads

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Constraints on current and other threads for the acquire memory order

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Constraints of release memory order on current thread, an acquiring thread and a consuming thread

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Three reasons why volatile cannot replace atomic access

A

May reorder past side effects as observed by another thread
May reorder other non volatile memory accesses
Not concurrent

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Four ways to pass an object to a function, and how it impacts the object ownership

A

Copy: Both
Reference: caller
Rvalue reference: callee
Forward reference: normal or rvalue reference

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Std::visit

A

Apply different functions to a variant object based on its current type

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

C++ RVO: d2

A

Return value optimization
Eliminate unnecessary copy for returned object

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

C++: pImpl Idiom - what, 2 benefits

A

Move private details into a separate structure
Compile time firewall
ABI stability

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Forward declaration: why, 4 uses, 2 not

A

Reduce compile time dependencies
Base classes, Member actual types
Pointer, reference, function parameter, function return

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Dependency injection: what

A

Technique in which an object or a function receives other objects and functions it needs, instead of creating them internally

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Dependency inversion pattern

A

Both higher and lower layers use abstractions to increase reuseability of higher layers

17
Q

Four execution policies

A

Sequenced, un sequenced, parallel, parallel unsequenced

18
Q

C++ algorithm for taking elements from one container to creating elements in another container

A

STD::transform

19
Q

What is an insert iterator

A

Calls the container’s insert method when assigned to

20
Q

C++ algorithm for filtering out elements from a range but don’t care about the order of the remaining elements

A

STD remove_if

21
Q

STD partition: 2 properties

A

C++ algorithm for dividing elements into two groups based on a condition and preserving the relative order within each group

22
Q

STD set_difference: what, how

A

Find differences between two sorted ranges
Copy elements from first range not in second range to output range

23
Q

4 meanings of f(x) in c++

A

Function call to f
A cast to type f
A function type
A declaration of x

24
Q

Std iota

A

Fill a range with sequentially increasing value

25
Q

aggregated struct: 4 criteria

A

No user defined constructors
No private or protected non static data members
No base classes
No virtual functions

26
Q

Aggregated structure: 2 benefits

A

Concise way to construct
More efficient to construct