Add resource "Technique: Immediately-Invoked Function Expression for Metaprogramming" Accepted
Changes: 7
-
Add Technique: Immediately-Invoked Function Expression for Metaprogramming
- Title
-
- Unchanged
- Technique: Immediately-Invoked Function Expression for Metaprogramming
- Type
-
- Unchanged
- Web
- Created
-
- Unchanged
- no value
- Description
-
- Unchanged
- Common C++ guidelines are to initialize variables on use and to make variables const whenever possible. But sometimes a variable is unchanged once initialized and the initialization is complex, like involving a loop. Then an IIFE – immediately-invoked function expression – can be used: the variable is initialized by a lambda that computes the value, which is then immediately invoked to produce the value. Then the variable is initialized on use and can also be made const. I’ve been recently working on a meta-programming library where I found IIFEs useful in a slightly different context – computing type information. TL;DR: decltype([] { ... } ())!
- Link
-
- Unchanged
- https://foonathan.net/2020/10/iife-metaprogramming/
- Identifier
-
- Unchanged
- no value
Resource | v1 | current (v1) -
Add Immediately invoked function expression
- Title
-
- Unchanged
- Immediately invoked function expression
- Description
-
- Unchanged
- An immediately invoked function expression (or IIFE, pronounced "iffy") is a JavaScript programming language idiom which produces a lexical scope using JavaScript's function scoping. Immediately invoked function expressions can be used to avoid variable hoisting from within blocks, protect against polluting the global environment and simultaneously allow public access to methods while retaining privacy for variables defined within the function.
- Link
-
- Unchanged
- https://en.wikipedia.org/?curid=38413545
Topic | v1 | current (v1) -
Add Decltype
- Title
-
- Unchanged
- Decltype
- Description
-
- Unchanged
- In the C++ programming language, decltype is a keyword used to query the type of an expression. Introduced in C++11, its primary intended use is in generic programming, where it is often difficult, or even impossible, to express types that depend on template parameters. As generic programming techniques became increasingly popular throughout the 1990s, the need for a type-deduction mechanism was recognized. Many compiler vendors implemented their own versions of the operator, typically called typeof, and some portable implementations with limited functionality, based on existing language features were developed. In 2002, Bjarne Stroustrup proposed that a standardized version of the operator be added to the C++ language, and suggested the name "decltype", to reflect that the operator would yield the "declared type" of an expression. decltype's semantics were designed to cater to both generic library writers and novice programmers.
- Link
-
- Unchanged
- https://en.wikipedia.org/?curid=24220775
Topic | v1 | current (v1) -
Add Immediately invoked function expression treated in Technique: Immediately-Invoked Function Expression for Metaprogramming
- Current
- treated in
Topic to resource relation | v1 -
Add Decltype treated in Technique: Immediately-Invoked Function Expression for Metaprogramming
- Current
- treated in
Topic to resource relation | v1 -
Add C++ parent of Decltype
- Current
- parent of
Topic to topic relation | v1 -
Add C++ parent of Immediately invoked function expression
- Current
- parent of
Topic to topic relation | v1