Category "c++17"

How to print a n-dimensional c++ STL container? Container is array of arrays or vectors of vectors

I have a code where I want to display tensor represented as vectors of vectors or std::arrays of std::arrays. The intention is to print them the way numpy print

How to create a simple version of std::function class

Suppose that I want to create a simple version ofstd::function, which has following behaviors: 1. function(){} -> A void constructor 2. function(_ReturnType,

Ambiguous partial specializations and enable_if_t

This question is due to insane curiosity rather than an actual problem. Consider the following code: template<typename...> struct type_list {}; template&

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

g++: error: unrecognized '-std=c++17' (what is g++ version and how to install)

I am working on RHEL 7.5 and trying to compile a uWebSocket (This exaple) code. I clone the project and open it. When I start make on Makefile I got this error;

Using queue Between two object of class

In order to send messages between two objects of class! I implemeted this class User { public: virtual void run() { while (true)

Overload a lambda function

How to overload a simple local lambda function? SSE of original problem: #include <iostream> #include <map> void read() { static std::string

Why is my parallel std::for_each only using 1 thread?

I'm trying to parallelize this C++ code (computing a continuous Fourier transform of points, modeled as Dirac impulses), and this code compiles and works correc

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