Tutorial by Examples

There are places in the standard where an object is copied or moved in order to initialize an object. Copy elision (sometimes called return value optimization) is an optimization whereby, under certain specific circumstances, a compiler is permitted to avoid the copy or move even though the standard...
C++17 Normally, elision is an optimization. While virtually every compiler support copy elision in the simplest of cases, having elision still places a particular burden on users. Namely, the type who's copy/move is being elided must still have the copy/move operation that was elided. For example:...
If you return a prvalue expression from a function, and the prvalue expression has the same type as the function's return type, then the copy from the prvalue temporary can be elided: std::string func() { return std::string("foo"); } Pretty much all compilers will elide the tempor...
When you pass an argument to a function, and the argument is a prvalue expression of the function's parameter type, and this type is not a reference, then the prvalue's construction can be elided. void func(std::string str) { ... } func(std::string("foo")); This says to create a tem...
If you return an lvalue expression from a function, and this lvalue: represents an automatic variable local to that function, which will be destroyed after the return the automatic variable is not a function parameter and the type of the variable is the same type as the function's return type ...
If you use a prvalue expression to copy initialize a variable, and that variable has the same type as the prvalue expression, then the copying can be elided. std::string str = std::string("foo"); Copy initialization effectively transforms this into std::string str("foo"); (th...
The bisect command helps you to track down the changeset that introduced a bug. Reset the bisect state and mark the current revision as bad (it contains the bug!) hg bisect --reset hg bisect --bad Go back to a point where you think the bug isn't present hg update -r -200 Now...
Serialization is the process of converting an object into a stream of bytes in order to store the object or transmit it to memory, a database, or a file. Microsoft page Serialization The following example demonstrates Serialization in WCF: [ServiceContract(Namespace="http://Microsoft.Ser...
Python 2.x2.7 In Python 2 filter, map and zip built-in functions return a sequence. map and zip always return a list while with filter the return type depends on the type of given parameter: >>> s = filter(lambda x: x.isalpha(), 'a1b2c3') >>> s 'abc' >>> s = map(lambd...
The partial function creates partial function application from another function. It is used to bind values to some of the function's arguments (or keyword arguments) and produce a callable without the already defined arguments. >>> from functools import partial >>> unhex = partia...
When we want to create an orderable class, normally we need to define the methods __eq()__, __lt__(), __le__(), __gt__() and __ge__(). The total_ordering decorator, applied to a class, permits the definition of __eq__() and only one between __lt__(), __le__(), __gt__() and __ge__(), and still allow...
In Python 3.x, the reduce function already explained here has been removed from the built-ins and must now be imported from functools. from functools import reduce def factorial(n): return reduce(lambda a, b: (a*b), range(1, n+1))
public class Foo { private const int TASK_ITERATION_DELAY_MS = 1000; private CancellationTokenSource _cts; public Foo() { this._cts = new CancellationTokenSource(); } public void StartExecution() { Task.Factory.StartNew(this.OwnCodeCancelable...
public class Foo { private CancellationTokenSource _cts; public Foo() { this._cts = new CancellationTokenSource(); } public void StartExecution() { Task.Factory.StartNew(this.OwnCodeCancelableTask, this._cts.Token); } public void Cance...
/// <summary> /// Registers a background task in the system waiting to trigger /// </summary> /// <param name="taskName">Name of the task. Has to be unique</param> /// <param name="taskEntryPoint">Entry point (Namespace) of the class (has to impl...
/// <summary> /// Gets a BackgroundTask by its name /// </summary> /// <param name="taskName">Name of the task to find</param> /// <returns>The found Task or null if none found</returns> public BackgroundTaskRegistration TaskByName(string taskName) ...
public sealed class BackgroundTask : IBackgroundTask { private BackgroundTaskDeferral _deferral; /// <summary> /// Registers the listener to check if the button is pressed /// </summary> /// <param name="taskInstance">An interface to an instan...
private bool IsTaskRegistered(string taskName) => BackgroundTaskRegistration.AllTasks.Any(x => x.Value.Name.Equals(taskName));
var trigger = new ApplicationTrigger(); TaskHandlerMentionedInThisTutorial.RegisterTask(TaskName, entryPoint, trigger, null, true); await trigger.RequestAsync();
/// <summary> /// Unregister a single background task with given name /// </summary> /// <param name="taskName">task name</param> /// <param name="cancelTask">true if task should be cancelled, false if allowed to finish</param> public void...

Page 311 of 1336