Category "c++17"

invalid declarator before std::variant

I'm trying to implement an ad-hoc light weight state machine using std::variant. However, it seems that the variant fsm isn't declared right as it fails with th

Generating compile time functions string for formatting strings with libfmt

I want to create a nice table in stdout. The table has a lot of headers that are mainly compiletime strings. For example: std::cout << fmt::format("|{0:-^

uWebSockets undefined references in eclipse cpp ide

I'm new to c++ and i miss many knowledge about it. Mostly i get the work done by try and error. But now i stuck on setting up a test project for a websocket se

Which STL data structures with an incomplete type stored can be used as a class member?

As far as I know, since C++17 some STL data structures may "exist" with an incomplete type as the template parameter which describes the type stored. For exampl

Private compile-time -> run-time adapter. Strange compilation error

Basically, this code fails with a very strange error: <source>:75:29: error: cannot convert 'get_view<main()::<unnamed struct>, run_time::data_vi

Why introduce `std::launder` rather than have the compiler take care of it?

I've just read What is the purpose of std::launder? and frankly, I am left scratching my head. Let's start with the second example in @NicolBolas' accepted answ

Named Parameter Idiom and non-copyable class

I am implementing a class that uses Named Parameter Idiom to initialise its members: class Person { public: Person & first_name(std::string n)

Ensure that char pointers always point to the same string literal

Given the code // somewhere in the program const char* p1 = "Hello World"; // somewhere else in the program const char* p2 = "Hello World"; is there a way t

What does the "operator()..." syntax mean in C++?

I'm trying to understand the example of std::visit from cppreference, Where I saw the following line of code: template<class... Ts> struct overloaded : T

How can I code something like a switch for std::variant?

I have some var = std::variant<std::monostate, a, b, c> when a, b, c is some types. How, at runtime, do I check what type var contains? In the official do

Range-v3 operator overloading to write shorter code

For my matrix class I want to do some sort of operator overloading (probably using expression templates) on range-v3 views for + - / * % . For example if I want

What is the purpose of std::launder?

P0137 introduces the function template std::launder and makes many, many changes to the standard in the sections concerning unions, lifetime, and pointers. Wh

c++ constexpr concatenate char*

Context: In my company we generate a lot of types based on IDL files. Some of the types require special logic so they are handcoded but follow the same pattern

Will C++17 allow forward declaration of nested classes?

Not sure where to ask (feel free to close this if it is an inappropriate question) but I have not found anything on this specifically in C++17 proposals, neithe

Ternary operator implicit cast to base class

Consider this piece of code: struct Base { int x; }; struct Bar : Base { int y; }; struct Foo : Base { int z; }; Bar* bar = new Bar; Foo* foo =

Unable to use std::apply on user-defined types

While implementing a compressed_tuple class for some project I'm working on, I ran into the following issue: I can't seem to pass instances of this type to std:

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

Algorithm to convert std::stack to std::string in C++ STL

In below C++ program I'm deleting a previous character considering '#' as a backspace character. I have used stack to build the string. Is there any C++ STL alg

Idiomatically split a string_view

I read The most elegant way to iterate the words of a string and enjoyed the succinctness of the answer. Now I want to do the same for string_view. Problem is,

Use of observer_ptr

What exactly is the point of the construct std::observer_ptr in the library fundamentals technical specification V2? It seems to me that all it does is wrap a