🍌 C++ Feed
306 subscribers
218 photos
12.7K links
Агрегатор всего подряд про C++.

Для связи: @smertig

Powered by https://github.com/Smertig/banana
Download Telegram
Fluent C++
How to Implement operator= When a Data Member Is a Lambda

In C++, some types of class members make it tricky to implement a copy assignment operator, operator=. For example references, const members, and… lambdas. Indeed, in the majority of cases, lambdas don’t have an operator=. (In case you’re wondering in what case lambdas have an operator=, it is in C++20 and when they don’t capture anything.) […]
The post How to Implement operator= When a Data Member Is a Lambda appeared first on Fluent C++.
foonathan::blog()
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([] { ... } ())!
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
Standard C++ (Twitter)

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
Standard C++ (Twitter)

False positives are our enemies, but may still be your friends -- Loic Joly bit.ly/3ldYaK5 #cpp
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]