async await performance?

Yes, in theory. Not normally, in the real world. In the common case, async is used for I/O-bound operations, and the overhead of thread management is undetectable in comparison to them. Most of the time, asynchronous operations either take a very long time (compared to thread management) or are already completed (e.g., a cache). Note …

Read more

What is a scalar Object in C++?

Short version: Types in C++ are: Object types: scalars, arrays, classes, unions Reference types Function types (Member types) [see below] void Long version Object types Scalars arithmetic (integral, float) pointers: T * for any type T enum pointer-to-member nullptr_t Arrays: T[] or T[N] for any complete, non-reference type T Classes: class Foo or struct Bar …

Read more

Calling base class overridden function from base class method

Unfortunately, no As i’m sure you’re aware, but I’ll state explicitly for completeness – there are only the 2 keywords to control the method invocation: this – this.method() – looks for method starting from the invoking instance’s class (the instance’s “top” virtual table – implied default) super – super.method() – looks for method starting from …

Read more

How a RegEx engine works [closed]

There are two main classes of regex engines. Those based on Finite State Automaton. These are generally the fastest. They work by building a state machine, and feeding it characters from the input string. It is difficult, if not impossible, to implement some more advanced features in engines like this. Examples of FSA based engines: …

Read more

How to test randomness (case in point – Shuffling)

Statistics. The de facto standard for testing RNGs is the Diehard suite (originally available at http://stat.fsu.edu/pub/diehard). Alternatively, the Ent program provides tests that are simpler to interpret but less comprehensive. As for shuffling algorithms, use a well-known algorithm such as Fisher-Yates (a.k.a “Knuth Shuffle”). The shuffle will be uniformly random so long as the underlying …

Read more

Exactly what is the difference between a “closure” and a “block”?

While a block is just a piece of code that can be composed by statements and declarations but nothing else, a closure is a real first-class object, a real variable that has a block as its value. The main difference is that a block simply groups instructions together (for example the body of a while …

Read more