foonathan::blog()
Technique: Immediately-Invoked Function Expression for Metaprogramming
Common C++ guidelines are to initialize variables on use and to make variables
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
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:
Technique: Immediately-Invoked Function Expression for Metaprogramming
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([] { ... } ())!www.foonathan.net
Technique: Immediately-Invoked Function Expression for Metaprogramming
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…
But sometimes a variable is unchanged once initialized and the initialization is complex, like involving a loop.
Then an IIFE – immediately-invoked function…
Arthur O’Dwyer
Solo-player rules for _Colossal Cave: The Board Game_
Back in 2013, I Kickstarted Colossal Cave: The Board Game, a board-game adaptation of Adventure.
(See the Kickstarter campaign here.
I’m quite proud of that campaign. You can still find copies of the game on Amazon.)
Seven years later, I’ve finally tried out a single-player variant originally inspired by
BoardGameGeek poster Tracy Smith,
and I’m pleased to say that it works pretty well! In this variant, you’re playing against the clock,
trying to deposit as many treasures as you can before the draw pile runs out.
On my first solo playthrough, I scored 6 treasures (out of a ...
Read full post
Solo-player rules for _Colossal Cave: The Board Game_
Back in 2013, I Kickstarted Colossal Cave: The Board Game, a board-game adaptation of Adventure.
(See the Kickstarter campaign here.
I’m quite proud of that campaign. You can still find copies of the game on Amazon.)
Seven years later, I’ve finally tried out a single-player variant originally inspired by
BoardGameGeek poster Tracy Smith,
and I’m pleased to say that it works pretty well! In this variant, you’re playing against the clock,
trying to deposit as many treasures as you can before the draw pile runs out.
On my first solo playthrough, I scored 6 treasures (out of a ...
Read full post
quuxplusone.github.io
Solo-player rules for Colossal Cave: The Board Game
Back in 2013, I Kickstarted Colossal Cave: The Board Game, a board-game adaptation of Adventure.
(See the Kickstarter campaign here.
I’m quite proud of that campaign. You can still find copies of the game on Amazon.)
Seven years later, I’ve finally tried…
(See the Kickstarter campaign here.
I’m quite proud of that campaign. You can still find copies of the game on Amazon.)
Seven years later, I’ve finally tried…
Standard C++ (Twitter)
Getting timely, accurate feedback on your C++ from the SonarQube ecosystem -- G. Ann Campbell bit.ly/30oS29G #cpp
Getting timely, accurate feedback on your C++ from the SonarQube ecosystem -- G. Ann Campbell bit.ly/30oS29G #cpp
Standard C++ (Twitter)
"C++ Move Semantics - The Compete Guide" is Complete and in Print -- Nicolai Josuttis bit.ly/3cT2jQs #cpp
"C++ Move Semantics - The Compete Guide" is Complete and in Print -- Nicolai Josuttis bit.ly/3cT2jQs #cpp
Standard C++ (Twitter)
False positives are our enemies, but may still be your friends -- Loic Joly bit.ly/3ldYaK5 #cpp
False positives are our enemies, but may still be your friends -- Loic Joly bit.ly/3ldYaK5 #cpp
C++
GDBFrontend v0.1.2-beta released with theming and a lot of improvements. You can contribute with new themes, plugins, commits or testing!
submitted by /u/EvrenselKisilik
[link] [comments]
GDBFrontend v0.1.2-beta released with theming and a lot of improvements. You can contribute with new themes, plugins, commits or testing!
submitted by /u/EvrenselKisilik
[link] [comments]
reddit
GDBFrontend v0.1.2-beta released with theming and a lot of...
Posted in r/cpp by u/EvrenselKisilik • 16 points and 0 comments
Standard C++ (Twitter)
Why it is important to apply static analysis for open libraries that you add to your project bit.ly/36rVJzh #cpp
Why it is important to apply static analysis for open libraries that you add to your project bit.ly/36rVJzh #cpp
Twitter
Standard C++
Why it is important to apply static analysis for open libraries that you add to your project https://t.co/5oxoTmRLuJ #cpp
C++
September's blog post - Improving compile times with Beast Websockets + clean shutdown of a complex application in response to Ctrl-C
submitted by /u/madmongo38
[link] [comments]
September's blog post - Improving compile times with Beast Websockets + clean shutdown of a complex application in response to Ctrl-C
submitted by /u/madmongo38
[link] [comments]
reddit
September's blog post - Improving compile times with Beast...
Posted in r/cpp by u/madmongo38 • 4 points and 0 comments
C++
Bad code you've written; then learned from
In my 10+ years of C++ing, one common thing I always encounter is that with every project I'm always learning something new about the language, the standard library, and other concepts. And a good part of it has come from writing code that eventually, and then fixing it. What's one of those things you've recently learned about C++ by having a program crash and then correcting the bug? (I'll put mine in the comments below). submitted by /u/def-pri-pub
[link] [comments]
Bad code you've written; then learned from
In my 10+ years of C++ing, one common thing I always encounter is that with every project I'm always learning something new about the language, the standard library, and other concepts. And a good part of it has come from writing code that eventually, and then fixing it. What's one of those things you've recently learned about C++ by having a program crash and then correcting the bug? (I'll put mine in the comments below). submitted by /u/def-pri-pub
[link] [comments]
reddit
Bad code you've written; then learned from
In my 10+ years of C++ing, one common thing I always encounter is that with every project I'm always learning something new about the language,...
C++
Copying struct values
I don't know if this a basic question. But have two vectors. One of my struct, the second of unsigned ints. Trying to copy a struct variable from the first to the second. My struct is as follows
[link] [comments]
Copying struct values
I don't know if this a basic question. But have two vectors. One of my struct, the second of unsigned ints. Trying to copy a struct variable from the first to the second. My struct is as follows
struct Process { unsigned pid, at, bt, ct; }; Am trying to copy my bt from the Process vector to the vector of unsigneds. Is there a way to do it with std::copy. std::for_each is the only other way I can seem to find submitted by /u/the_otaku_programmer [link] [comments]
reddit
Copying struct values
I don't know if this a basic question. But have two vectors. One of my struct, the second of unsigned ints. Trying to copy a struct variable from...