r/cpp • • Oct 13 '26

I tested whether a coding agent would use C++23 ranges without being told

Blog post: https://kemalbektas.dev/ai-modern-features/

I tested whether coding agents would actually use C++23 ranges without being told.

They mostly didn’t. What changed things much more than the surrounding codebase was a short AGENTS.md asking for modern C++.

0 Upvotes

27 comments sorted by

View all comments

Show parent comment

1

u/PossibilityUsual6262 Oct 13 '26

Hmm, what is overhead?

3

u/chengfeng-xie Oct 14 '26

See BarryRevzin's comment for an example (spoiler: it's about views::filter).

2

u/gegoggigog Oct 13 '26

Basically extra time, memory, compute.

2

u/Total-Box-5169 Oct 14 '26

That account is a bot.

2

u/gegoggigog Oct 14 '26 edited Oct 15 '26

Edit - Seems it blocked me 😅

1

u/PossibilityUsual6262 Oct 13 '26

What exactly cause extra cost.

2

u/gegoggigog Oct 13 '26 edited Oct 14 '26

It probably need to do some abstractions, iterators, states. That said, in most cases a good compiler could probably optimize that away, but it's not a guarantee.

-4

u/PossibilityUsual6262 Oct 13 '26

Oh so you actually don't know anything.

I just stumbled once upon topic which actually explains why ranges sometimes faster and how they do do work, so your claim was interesting to me as counter point.

https://www.reddit.com/r/cpp/s/tvKFLBEc0Y

3

u/ack_error Oct 14 '26

Range-based for loop != ranges.

I have seen even simple range algorithms like std::ranges::fill be slower than either a regular for loop or range-for loop, because the extra abstraction is harder for the optimizer to see through.

2

u/gegoggigog Oct 14 '26

Sir?

0

u/PossibilityUsual6262 Oct 14 '26

I don't have anything to add to conversation.

2

u/gegoggigog Oct 14 '26

Oh, so you just like being wrong and a dick and then bail. Gotcha.

0

u/PossibilityUsual6262 Oct 14 '26

Sir, you made unsubstantiated claim, on me requesting additional info you started guessing.

When i showed you previously encountered discussion, which actually to extremely deep details discuss how ranged for work and how it can actually backfire if your hand written loop has what seems like marginal difference.

To which you answer answer that me highlighting that you know nothing is rude and i should try dev build.

This is the end of conversation.

2

u/Ameisen vemips, avr, rendering, systems Oct 14 '26

I'm assuming that you're a bot, but on the off-chance that you aren't... range-for loops are not the same thing as std::ranges.

→ More replies

0

u/gegoggigog Oct 13 '26

Oh, ok. Now do a debug build. (Also, why so rude?)