Category "c++20"

Coroutines are not distributed over asio::thread_pool threads

I wanted to try out to c++20 coroutines together with asio. In a simple test three are coroutines which would be executed on a asio::thread_pool with 4 threads.

c++20 ranges view to vector

Now that the C++20 ranges implementation is actually here and released under GCC 10.2, I would like to know how to convert a ranges view back to an actual conta

`make_unique_for_overwrite` still initializes `std::pair` elements

I was hoping that auto myPairs = make_unique_for_overwrite<pair<uint64_t, void*>[]>(arraySize); would give me uninitialized memory for my pairs. I

Calling `std::vector<A>::data()` on `A` with const or reference fields, before C++20

This is a followup on the answers for placement new on a class with reference field. Calling std::vector<A>::data() on type A that has reference or const

How can I get a consistent, unique, identifier for a unique class combination?

I need a way to identify a unique combination of template types that gives me an easily indexable identifier. I have the following class: #include <cstdint&g

How to use c++20 modules with CMake?

Clang and MSVC already supports Modules TS from unfinished C++20 standard. Can I build my modules based project with CMake or other build system and how? I tri

Convert between std::u8string and std::string

C++20 added char8_t and std::u8string for UTF-8. However, there is no UTF-8 version of std::cout and OS APIs mostly expect char and execution character set. So

Convert between std::u8string and std::string

C++20 added char8_t and std::u8string for UTF-8. However, there is no UTF-8 version of std::cout and OS APIs mostly expect char and execution character set. So

How to make a templated parameter to match the function-signature of an outer templated type

Imagine I've got sth. like this: template<typename Signature> struct Callable { template<typename FnType> requires std::convertible_to&l

Why is volatile deprecated in C++20?

According to cppreference, most uses of the volatile keyword are to be deprecated in C++20. What is the disadvantage of volatile? And what is the alternative so

Escape sequences for char8_t and unsigned char

Trying to use escape sequences to construct a char8_t string (to not rely on file/compiler encoding), I got issue with MSVC. I wonder if it is a bug, or if it i

Does GCC support C++20 std::format?

If it doesn't, do you know what compiler or version will? See cppreference/format.

Why is Signed Overflow due to computation still Undefined Behavior in C++20

I came to know through this answer that: Signed overflow due to computation is still undefined behavior in C++20 while Signed overflow due to conversion is wel

Two ways of calling coroutines nestedly?

Imagine you have those coroutines awaitable<void> a() { ... } awaitable<void> b() { co_await a(); } awaitable<void> c() { co_await

How to compile/use header unit modules under CLang C++?

It is said in docs that modules support in CLang is partial. I'm using CLang under Windows 64-bit from recent release of LLVM 12.0. I successfully managed to us

How to create a time point from milliseconds since Unix epoch?

To create a time point for the current time, you can use: std::chrono::system_clock::now(). I cannot figure out, however, how to create a time point given milli

Import std lib as modules with clang

I am experimenting with modules in clang, and would like to include the standard lib as modules instead of as includes. Currently I do this #include <iostrea

Problem with std::index_sequence_for as default argument?

The following C++20 program: #include <utility> #include <cstddef> template<typename... Args> class C { template<size_t... I> s

Is there any way to declare a array, not just its elements, as const?

Using std::array I can declare both the array itself and it's objects as const. const std::array<const int,2> a {1,2}; However, if I read the standard co

Scheduling a coroutine with a context

There are plenty of tutorials that explain how it's easy to use coroutines in C++, but I've spent a lot of time getting how to schedule "detached" coroutines. A