News for hackers. Stuff that matters.
Re:C++ by Example by ur-whale on Thursday September 22, 2022 @09:43AM (#32938640)
Where's the template metaprogramming section?

What about the double bracket operator?

etc...

Or, to put it another way: very nice website for basic exposure but mostly demonstrates very basic stuff.

Re:C++ by Example by jvanderbot on Thursday September 22, 2022 @09:51AM (#32938725)
Yeah, it's fairly basic, and most of this is in the usual c++ docs like cppreference.com

But... Is template meta-programming a required feature of a C++ dev?

double-bracket is ... an edge case of usual [] overloading, isn't it?

Re:C++ by Example by ur-whale on Thursday September 22, 2022 @10:00AM (#32938840)
These are just examples to make a point.

And: https://arne-mertz.de/2016/12/modern-c-features-attributes/

Re:C++ by Example by stonemetal12 on Thursday September 22, 2022 @10:21AM (#32939130)
Templates are a major feature of the language, leaving it out seems a little weird.
Re:C++ by Example by d_tr on Thursday September 22, 2022 @11:41AM (#32940502)
Looks like an ongoing work so more will probably be available in the future. I see an example for templates. Template metaprogramming is more advanced but would be nice to include.
Re:C++ by Example by sva_ on Thursday September 22, 2022 @01:44PM (#32942246)
Re:C++ by Example by ur-whale on Thursday September 22, 2022 @03:55PM (#32943862)
That's just templates.

I'm talking about stuff like this:

https://en.wikipedia.org/wiki/Template_metaprogramming#Stati...

Re:C++ by Example by ncmncm on Thursday September 22, 2022 @01:21PM (#32941922)
It has been years since I was tempted to template metaprogramming. It is a specialist technique being made redundant by straightforward language features that compile much faster.
Re:C++ by Example by jvanderbot on Thursday September 22, 2022 @07:17PM (#32945887)
Yeah. I've never seen this in practice except as premature optimization or solving a problem in code that can be solved easier elsewhere.
Re:C++ by Example by sudosysgen on Thursday September 22, 2022 @11:25AM (#32940208)
I don't see what special about double brackets? It's just calling the operator again on the result, completely intuitive.
Re:C++ by Example by edflsafoiewq on Thursday September 22, 2022 @11:39AM (#32940458)
He means attributes, eg [[nodiscard]]. Of course you shouldn't call them operators.
Re:C++ by Example by MauranKilom on Thursday September 22, 2022 @12:29PM (#32941225)
See, I assumed they meant the >> operator. That used to (long ago) be cause for grief in e.g. std::vector<std::vector<int>> where the parser would see a >> operator instead of two closing angle brackets (since fixed by changing the grammar).
Re:C++ by Example by tialaramex on Thursday September 22, 2022 @05:34PM (#32944910)
So, there are four things which might get colloquially called "Brackets", they each have other names but...

(Round) brackets are Parentheses

{Curly} brackets are Braces

<Angle> brackets are Chevrons

[Square] brackets are often just Brackets

Ah, so there's the problem. Now, this actually also differs depending on English variant. In England it would be pretty normal to say "Brackets" and mean Parentheses, whereas in the US you'd mean the square brackets. Some English speakers outside the US might call the Square Brackets "Crotchets" to distinguish them, not so many. US English dominates in technology.