News

C++20 Lambda Extensions: Lambda Default Constructors -- Gajendra Gulgulia

GajendraGulgulia.pngIn this article, I cover Default constructuctible lambdas.

C++20 Lambda Extensions: Lambda Default Constructors

by Gajendra Gulgulia

From the article:

1. Default construction: Very short background

In C++ objects are default constructible if they satisfy certain conditions. The set of conditions vary and I’ll not go into all the details of what they are as it will be out of the scope of this article. Consider the Person class with default constructor in line 3. 

class Person{
    public:
         Person() = default;   //default constructor
         Person(std::uint32_t age, std::string name):
         age_{age}, name_{name}
         { /*empty body */ }

         std::string getName()  const { return name_;}
         std::uint32_t getAge() const { return age_; }
        
        void setAge(const std::uint32_t age) {age_ = age;}
        void setName(const std::string& name){name_ = name;}
   private:
       std::uint32_t age_{};
       std::string name_{};
};

TCP/IP Networking with Boost.Asio -- Richard Thomson

Utah C++ Programmers has released a new video:

TCP/IP Networking with Boost.Asio

by Richard Thomson

From the video description:

Boost.Asio is a cross-platform C++ library for network and low-level I/O programming that provides developers with a consistent asynchronous model using a modern C++ approach.

This month, Richard Thomson will continue our look at Boost.Asio with a look at TCP/IP networking. We'll look at how to implement an NNTP (Network News Transport Protocol) client using Boost.Asio. NNTP is a line-oriented protocol for reading usenet news articles. This will give us insight into all the typical issues involved in a TCP/IP networking application:

- How do we resolve a host name into an IP address?
- How do we establish a long-lived connection to an NNTP server?
- How do we handle the arbitrarily large amounts of data from an NNTP server that arrives asynchronously?
- How do we coordinate user input with NNTP I/O?
- How do we handle unexpected network errors?

https://www.youtube.com/watch?v=tyDWXT8-Ykc

C++23’s New Fold Algorithms -- Sy Brand

If you want to find out more about the std::ranges::fold_* algorithms in C++23, here's a new post for you.

C++23’s New Fold Algorithms

By Sy Brand

From the article:

C++20 added new versions of the standard library algorithms which take ranges as their first argument rather than iterator pairs, alongside other improvements. However, key algorithms like std::accumulate were not updated. This has been done in C++23, with the new std::ranges::fold_* family of algorithms.

Announcing Meeting C++ 2023

Today this years edition of the Meeting C++ conference has been announced:

Announcing Meeting C++ 2023

by Jens Weller

From the article:

This years Meeting C++ conference will be held in Berlin on the 12th - 14th November!

Like in the previous year, we will be hosting 3 tracks on site and plan for a prerecorded online track. The online part also will include live streams from all onsite talk tracks.

Tickets are available via event brite...

 

Layers -- Rainer Grimm

The layers pattern splits a task into horizontal layers. Each layer has a specific responsibility and provides a service to a higher layer.

Layers

by Rainer Grimm

From the article:

The Layers Pattern is an architectural pattern that helps, according to the book "Pattern-Oriented Software Architecture, Volume 1", to bring structure into the mud.

Although not specified, most layered architectures consist of three or four layers. Each layer is independent of the other layer. In the pure version, a layer can only access its layer below. A layer can not access its upper layer because it would create additional dependencies and complicates the control structure. Additionally, another application cannot easily use a layer that depends on an upper layer. A layer often provides its functionality by implementing the Facade Pattern. The Facade Pattern provides a simplified interface to a complex system.

C++20 Lambda Expressions, Non-type Template Parameters, Constraints and Concepts -- Gajendra Gulguli

How to write a class and fuction template declaration which uses functions and lambda expressions as non-type template parameter.

C++20 Lambda Expressions, Non-type Template Parameters, Constraints and Concepts

by Gajendra Gulgulia

From the article:

In this article I will explain how to write a class and fuction template declaration which uses functions and lambda expressions as non-type template parameter.

Function as Non-Type-Template-Parameter ( NTTP henceforth) looks like below in class and function template as of C++17.

template<auto FunctionType> class Foo{
// ...
};

template<atuo FunctionType>
void foo();

Pipes-and-Filters -- Rainer Grimm

The Pipes-and-Filters architecture pattern describes the structure of systems that process data streams.

Pipes-and-Filters

by Rainer Grimm

From the article:

The Pipes-and-Filters pattern is similar to the Layers Pattern. The idea of the Layers Pattern is to structure the system in layers so that higher layers are based on the services of lower layers. The Pipes-and-Filters naturally extend the Layers Pattern, using the layers as filters and the data flow as pipes.

Hardening C++ with Bjarne Stroustrup

An interview in Software Engineering Daily with Bjarne on the recent announcements by the NSA and the forthcoming CRA from the EU against the use of C++ based on security concerns.

Hardening C++ with Bjarne
Bjarne Stroustrup

From the interview:

Bjarne wishes for more support rather than calls to drop the use and teaching of C++ altogether. Especially in light of how much progress the C++ 17, 20 and 23 mean to the language but also how using the core guidelines and modern static analysis can reduce vulnerabilities considerably. 

Is boyer_moore_horspool faster then std::string::find?

The last blog post by Julien Jorge made me wonder if the string searchers could be faster here.

Is boyer_moore_horspool faster then std::string::find?

by Jens Weller

From the article:

On Wednesday I've read an interesting blog post by Julien Jorge on Effortful Performance Improvements, where it is shown how to improve an replace function which runs replacements on a string. Its part of a series on performance and improving a code base, you should go read all of them!

When reading the post, and seeing the two implementations, one short and simple and the other longer and more complicated - but faster - I wondered is there a faster way? Julien already has shown that his newer function beats his old function which uses std::string::find in performance. I've veryfied that, and then started to refactor a copy of that slower function with a different approach using the string search algorithm boyer_moore_horspool...

 

Workshops for C++ on Sea 2023

The C++ on Sea 2023 pre-conference, one-day workshops, are now available:

Workshops for C++ on Sea 2023

by C++ on Sea

About the workshops

Workshops on coroutines, concurrency and modern C++ idioms from Nathan Baggs, Rainer Grimm and Mateusz Pusz, respectively.