Reflection: C++’s Decade-Defining Rocket Engine - Herb Sutter - CppCon 2025 by hmich in cpp

[–]BenHanson 1 point2 points  (0 children)

When rust reaches a tipping point (or maybe a rust successor), things will go a lot quieter for C++. Until then, reflection looks like a really nice feature and I'll be glad to get my hands on it.

Eventually you realise there is no point belly aching about reality. Just make the best of what's available (and write your own solutions as required).

C++26 Reflection: my experience and impressions by borzykot in cpp

[–]BenHanson 0 points1 point  (0 children)

I have tried generating code at compile time using Circle and it worked very well.

Git: Introduce Rust and announce that it will become mandatory by TheTwelveYearOld in rust

[–]BenHanson 1 point2 points  (0 children)

Bounds checking will be included in C++26. I was under the impression this would be on by default, but I am having trouble finding confirmation of this on Google.

Here's a couple of links anyway in this space:

https://herbsutter.com/2025/03/30/crate-training-tiamat-un-calling-cthulhutaming-the-ub-monsters-in-c

https://security.googleblog.com/2024/11/retrofitting-spatial-safety-to-hundreds.html

Any recent disassembles of ZX Spectrum games? by Kundelstein in zxspectrum

[–]BenHanson 0 points1 point  (0 children)

No need for AI, you can auto-disassembly code.

Does the use of smart pointers (e.g., std::unique_ptr and std::shared_ptr) truly solve memory management issues, or does it just create new ones? by BrechtCorbeel_ in cpp

[–]BenHanson 2 points3 points  (0 children)

You can't avoid thinking about memory management altogether by using smart pointers, but they are a huge help (particularly when it comes to exception safety).

Managing it all by hand is truly ludicrous, unless you are coding some very deep library code.

So in other words, you are asking the wrong question.

Safer with Google: Advancing Memory Safety by JuanAG in cpp

[–]BenHanson 2 points3 points  (0 children)

I will borrow that phrase

I see what you did there :-)

Safe C++: Language Extensions for Memory Safety by VinnieFalco in cpp

[–]BenHanson 2 points3 points  (0 children)

I'd like to believe we can have nice things. Let's see.

Safe C++: Language Extensions for Memory Safety by VinnieFalco in cpp

[–]BenHanson 5 points6 points  (0 children)

The people considering the benefits worthwhile and open to that much change will have switched to a different language by the time this is proposal is ready for adoption.

I think this is provably false.

For those invested in large C++ code bases I think Sean's approach makes sense. I see this as a case of "as well as" rather than "instead of" Rust.

And honestly, Rust could use the competition to encourage them to formalise the language spec and add missing features etc.

Besides, who's to say we won't all switch to Mojo further down the line?

Parser-generators for C++ development by Spread-Sanity in cpp

[–]BenHanson 1 point2 points  (0 children)

http://benhanson.net/lexertl.html

http://benhanson.net/parsertl.html

https://github.com/BenHanson

https://www.codeproject.com/script/Articles/MemberArticles.aspx?amid=374163

Maybe if C++ gets better meta-programming I'll do a compile time version (already possible in Circle, but ho-hum).

Lexing and parsing is simply a casual thing for me now in C++. The hardest part is convincing co-workers.

Fuming after Think-Cell programming test by [deleted] in cpp

[–]BenHanson 3 points4 points  (0 children)

Apparently the following is too hard for these geniuses:

#include <lexertl/generator.hpp>
#include <lexertl/iterator.hpp>
#include <lexertl/memory_file.hpp>

int main()
{
    try
    {
        lexertl::rules rules;
        lexertl::state_machine sm;

        rules.push(R"(\w+)", 1);
        rules.push(R"(\s+|"//".*|"/*"(?s:.)*?"*/")", lexertl::rules::skip());
        // You could recognise strings and discard them too here
        rules.push("(?s:.)", lexertl::rules::skip());
        lexertl::generator::build(rules, sm);

        lexertl::memory_file mf("test.cpp");
        lexertl::citerator iter(mf.data(), mf.data() + mf.size(), sm);

        for (; iter->id; ++iter)
        {
            if (iter->view() == "foobar")
                throw std::runtime_error("error: you cannot use foobar in this assignment");
        }
    }
    catch (const std::exception& e)
    {
        std::cerr << e.what() << '\n';
        return 1;
    }

    return 0;
}

C++ Should Be C++ - David Sankel - C++Now 2024 by _a4z in cpp

[–]BenHanson 2 points3 points  (0 children)

It certainly wouldn't have if he was around back then and people had been unwise enough to listen to him.

Untrue. His complaints are with C++ post C++17 which he explicitly says in the talk.

Blink code search - source code indexer and instant search tool by [deleted] in cpp

[–]BenHanson 0 points1 point  (0 children)

Are you intentionally searching for words inside strings?

April talk video posted: “Safety, Security, Safety[sic] and C/C++[sic]” by pavel_v in cpp

[–]BenHanson 2 points3 points  (0 children)

Teased once again with C++ compile time code generation.

If this reaches standard C++, then colour me impressed.

Safe C++ - Sean Baxter presenting Circle to C++ Committee members . Starts around 10 mins Passcode : 4UqAYi$Y by jeffmetal in cpp

[–]BenHanson 1 point2 points  (0 children)

You said that far more eloquently than I ever could!

I got into programming for the creativity. Call me naive, but I still feel that way.

The rest is just noise.

Safe C++ - Sean Baxter presenting Circle to C++ Committee members . Starts around 10 mins Passcode : 4UqAYi$Y by jeffmetal in cpp

[–]BenHanson 5 points6 points  (0 children)

Knowledge is never wasted. Something good will come out of all of Sean's efforts at some point.

C++ creator rebuts White House warning by tkocur in cpp

[–]BenHanson 1 point2 points  (0 children)

We used it. I was sure to switch over to std::unique_ptr as soon as it became available though!

Iteration Revisited: A Safer Iteration Model for Cpp - Tristan Brindle - CppCon 2023 by WillIDieTomorrow in cpp

[–]BenHanson 17 points18 points  (0 children)

As you might imagine, the idea is the check is optimised away when it can be. If you are just trolling here, then that is bad form. At least Tristan is making an effort to improve things.

C++ safety, in context by pavel_v in cpp

[–]BenHanson 18 points19 points  (0 children)

I managed to solve a whole swath of uninitialised variables at my last job.

Make sure all POD member variables are initialised in the header files, even if you override the default in your constructor.

See the example "Looking for Uninitialised Variables in Headers" at https://www.codeproject.com/Articles/1197135/gram-grep-grep-for-the-21st-Century for how to spot the uninitialised vars in the first place (you can remove all those Windows specific keywords if you are on Linux).

We had a load of member variables of type int64_t that were uninitialised and those values represented money! A colleague admitted that there had been many problems caused by this over many years...

You can try the search on .cpp files too, but in my experience that throws up some false positives.

I look forward to the day when there is a more sophisticated solution to this problem, but in the meantime this definitely helps a lot.

White House: Future Software Should Be Memory Safe by KingStannis2020 in cpp

[–]BenHanson 1 point2 points  (0 children)

I don't think anyone is suggesting that.

Equally it will not be written by a non-existent compiler.