Advertisement · 728 × 90
#
Hashtag
#ModernCpp
Advertisement · 728 × 90
Preview
Release Explosieve Spring · IJHack/QtPass Highlights Windows release pipeline reliability improvements for AppVeyor and Inno Setup packaging. Modernized C++/Qt build pipeline with clang-tidy and wider lint/test hardening. 1.5.0 release me...

QtPass 1.5.0 is out.

Modern C++17, combined with improved Qt support, add in fixes, cleanup, packaging work, CI and linting improvements, and updated translations.
Release notes: <https://github.com/IJHack/QtPass/releases/tag/v1.5.0>
#QtPass #Qt #CPP17 #ModernCpp #FOSS #PasswordStore

1 0 0 0
Screenshot of a code snippet containing two functions written in C++.

The first function is called `CreateServiceProvider()` and uses a pattern closely resembling modern .NET dependency injectors. It calls `services.AddSingleton<>()` to register a `ProjectService` and a `ProjectDatabase`, then calls `MvvmServicesRegistrator::Register()` to automatically add the entire MVVM subsystem to the dependency injector.

The second function is called `BindViewModels()` and grabs the `WindowManager` out of the dependency injector, then calls `BindViewModel<MainViewModel, MainWindow>()` to automatically associate the `MainViewModel` with the `MainWindow`.

Later on, the application can simply instruct the `WindowManager` to display a window for the `MainViewModel` and it will figure out everything - which Qt Widgets main window class to use, which view model to construct and its constructor-injected dependencies, too - just like it would be in a modern .NET environment.

Screenshot of a code snippet containing two functions written in C++. The first function is called `CreateServiceProvider()` and uses a pattern closely resembling modern .NET dependency injectors. It calls `services.AddSingleton<>()` to register a `ProjectService` and a `ProjectDatabase`, then calls `MvvmServicesRegistrator::Register()` to automatically add the entire MVVM subsystem to the dependency injector. The second function is called `BindViewModels()` and grabs the `WindowManager` out of the dependency injector, then calls `BindViewModel<MainViewModel, MainWindow>()` to automatically associate the `MainViewModel` with the `MainWindow`. Later on, the application can simply instruct the `WindowManager` to display a window for the `MainViewModel` and it will figure out everything - which Qt Widgets main window class to use, which view model to construct and its constructor-injected dependencies, too - just like it would be in a modern .NET environment.

That was easier than I thought.

Simple WindowManager class, one-line View <-> ViewModel binding, view model is constructed through dependency injector, so just adding services as constructor parameters provides them to the view model with no other change :)

#cxx #programming #moderncpp

1 0 0 0
Screenshot of a unit test that serves as example of the C++ dependency injector.

At the top, it creates a `StandardServiceCollection` and calls `AddSingleton<Interface, Implementation>()` on it to register two services. The constructor arguments of the `Implementation` classes are automatically detected via template magic.

It then calls `BuildServiceProvider()` on the `StandardServiceCollection` to produce a `ServiceProvider` instance.

From this instance, it requests one of the registered services (by its interface) and calls a method on that demonstrates that other service, which it depends on through the implementaiton class' constructor arguments, had been provided to the constructor when it was called (recursive dependency resolution).

Screenshot of a unit test that serves as example of the C++ dependency injector. At the top, it creates a `StandardServiceCollection` and calls `AddSingleton<Interface, Implementation>()` on it to register two services. The constructor arguments of the `Implementation` classes are automatically detected via template magic. It then calls `BuildServiceProvider()` on the `StandardServiceCollection` to produce a `ServiceProvider` instance. From this instance, it requests one of the registered services (by its interface) and calls a method on that demonstrates that other service, which it depends on through the implementaiton class' constructor arguments, had been provided to the constructor when it was called (recursive dependency resolution).

My C++20 dependency injector rewrite is coming along.

It's loosely inspired by Microsoft.Extensions.DependencyInjection, with a ServiceCollection, .AddSingleton<Ifc,Impl>(), service scopes, automatic constructor argument detection, all done in pure C++20.

#programming #moderncpp #templates

2 0 1 0
Screenshot of a C++20 code snippet that registers an entity class for a database table:

```
r.RegisterTable<TestEntity>(u8"users").
  WithColumn<&TestEntity::Id>(u8"id").NotNull().AutoGenerated().PrimaryKey().
  WithColumn<&TestEntity::Name>(u8"name").NotNull().
  WithColumn<&TestEntity::PasswordHash>(u8"passwordHash");
```

Screenshot of a C++20 code snippet that registers an entity class for a database table: ``` r.RegisterTable<TestEntity>(u8"users"). WithColumn<&TestEntity::Id>(u8"id").NotNull().AutoGenerated().PrimaryKey(). WithColumn<&TestEntity::Name>(u8"name").NotNull(). WithColumn<&TestEntity::PasswordHash>(u8"passwordHash"); ```

Screenshot of a C++20 code snippet that executes a "fluent" query on a database table using a registered entity class:

```
std::optional<User> johnUser = myProjectDataContext.Users.
  Where(Column(&User::Name) == u8"John")).
  SingleOrDefault();
```

Screenshot of a C++20 code snippet that executes a "fluent" query on a database table using a registered entity class: ``` std::optional<User> johnUser = myProjectDataContext.Users. Where(Column(&User::Name) == u8"John")). SingleOrDefault(); ```

The neat "mini" ORM for C++20 I started recently turned out very well and is already seeing use :)

github.com/nuclex-share...

The registration of entity classes is very easy now, too. Just the fluent query system and a packageable CMake build remain.

#programming #cxx #cplusplus #moderncpp

2 0 0 0
- YouTube
- YouTube Enjoy the videos and music you love, upload original content, and share it all with friends, family, and the world on YouTube.

Channel9 Should people move old C++ to modern C++? #CPlusPlus #ModernCPP #DeveloperSecurity

0 0 0 0

Explore the latest advances in modern C++ programming! Understand new features, improved performance, and practical implications for developers. Tap into powerful tools for more efficient coding. #CPlusPlus #ModernCpp

0 0 0 0
C++ fragments using requires clause with front and tail syntax.

```C++
    template<typename... Ts>
        requires((std::constructible_from<QStringView, Ts>
                  || std::constructible_from<QLatin1String, Ts>) && ...)
    static void reportError(QStringView format, Ts &&...args)
```

```C++
    template<typename... Ts>
    static void reportError(QStringView format, Ts &&...args)
        requires((std::constructible_from<QStringView, Ts>
                  || std::constructible_from<QLatin1String, Ts>) && ...)
    {
```

C++ fragments using requires clause with front and tail syntax. ```C++ template<typename... Ts> requires((std::constructible_from<QStringView, Ts> || std::constructible_from<QLatin1String, Ts>) && ...) static void reportError(QStringView format, Ts &&...args) ``` ```C++ template<typename... Ts> static void reportError(QStringView format, Ts &&...args) requires((std::constructible_from<QStringView, Ts> || std::constructible_from<QLatin1String, Ts>) && ...) { ```

I am pretty sure you all already know, but it's actually possible to have `requires` clauses at the end of a function declaration. Just like any other attribute.

This makes usage of ad-hoc requirements much more readable and greatly reduces the pressure to […]

[Original post on mastodon.green]

0 1 0 0
Original post on mastodon.green

You don't realize just how good C++23 is until you take some old C++ code, paste it into #Godbolt, set the compiler flags to C++23, add a few concept-checking asserts, read the beautifully clear error messages from concepts, and fix your problem.

#ModernCPP #CPP #Concepts #Legacy #Evolution […]

1 1 0 0
Owning and non-owning C++ Ranges

2025-05-17 16 min read 

This is the first article in a series discussing some of the underlying properties of C++ ranges and in particular range adaptors. At the same time, I introduce the design of an experimental library which aims to solve some of the problems discussed here.

Owning and non-owning C++ Ranges 2025-05-17 16 min read This is the first article in a series discussing some of the underlying properties of C++ ranges and in particular range adaptors. At the same time, I introduce the design of an experimental library which aims to solve some of the problems discussed here.

I wrote a blog post:

𝗢𝘄𝗻𝗶𝗻𝗴 𝗮𝗻𝗱 𝗻𝗼𝗻-𝗼𝘄𝗻𝗶𝗻𝗴 𝗖++ 𝗥𝗮𝗻𝗴𝗲𝘀

The first article in a series discussing some of the underlying properties of C++ ranges, and in particular range adaptors.

hannes.hauswedell.net/post/2025/05...

#cplusplus #moderncpp #programming #cpp #ranges

3 0 0 0
Preview
Join my Mastering C++ Templates self-study course

Templates in C++ are powerful – but they’re also one of the most misunderstood features.
Ready to rewind, revisit, and truly master templates on your term? Book before April 30th and get a free copy of my "Tips and Tricks with Templates" book.

#programming #cpptemplates #ModernCpp

3 2 0 0
Preview
C++ Is 45 Years Old. [Stroustrup] Says You Still Don’t Get It! We were surprised when we read a post from C++ creator [Bjarne Stroustrup] that reminded us that C++ is 45 years old. His premise is that C++ is robust and flexible and by following some key precep…

C++ Is 45 Years Old. [Stroustrup] Says You Still Don’t Get It!

hackaday.com/2025/02/09/c...
#CPlusPlus #C++ #45Years #Stroustrup #Wisdom #ModernCPP #CodeLegacy #Programming #Evolution #DevLife #Software #Engineering

0 0 0 0
Post image

Improve code safety and efficiency with "Modern C++ Paradigms" at the KDAB Training Day (8 May). This one-day training course covers value semantics, modern error handling, range-based programming, and more. Early bird tickets on training.kdab.com/ktd25/ #Cpp #ModernCpp #CPlusPlus

0 0 0 0