I have very simple code here with a Rectangle and Circle class inheriting from Shape class, and output their area and perimeter. I can't figure out wh ...
I have very simple code here with a Rectangle and Circle class inheriting from Shape class, and output their area and perimeter. I can't figure out wh ...
I have a struct like: Now I want to initialize the struct using initializer list as following: However, this doesn't work. How do I initialize t ...
I have the following code: Is there any way to get number of entries in INIT_LIST at compile time? ...
The following C++ code compiles with no errors or warnings, but for some reason when I print out the contents of foo.arr I just get junk values. It lo ...
I have a class (foo) that has a member (c) that I want to be a two-dimensional array of integers. For some reason I can't get the initializer list to ...
I have an integer_sequence and I need to create std::initializer_list for constructor of std::map. The idea is below: There std::initializer_list i ...
I am trying to create a function that will initialize an internal std::set<std::string>, and I want to expose an API that allows any type of ran ...
In the following example below (c++11): #include <iostream> struct foo { foo() = default; foo(int x): v1{x} {} int v1 = 0; in ...
I am attempting to build a Tic Tac Toe game in C++, however, I am very beginner in C++ but can code reasonably confidently in Python. This is my code ...
I ask because auto deduces{} to be initializer_list. I don't know of any other class in the standard library that the core language depends on like th ...
I would like to write some code like the following: Is there some way to fix the implementation of CombinedBox, so that SevenDimensionalBox::kDims ...
When I'm trying to compile the following code, the compiler complains: The compiler (gcc) gives me the following error: But when I tried to use ...
In my project there is need to append initializer list at runtime. I have figured the way to have initializer_list std::initializer_list<std::pair ...
I was playing with concepts (I wanted to give this question a C++ey answer) and came across a behavior with std::initializer_list that puzzles me. Alt ...
A class (dLinkedList) need to have different c-tors: [please don't suggest to use STL containers!] However, the c-tor with initializer_list seems t ...
let's say i have a template function taking a class object: and a class definition as follows: is there a way to make the following code compile ...
Why does c++ choose a primitive type overload match over a "better" matching initializer list? #include <vector> void foo([[maybe_unused]] in ...
I just read the following article from Raymond Chen's excellent 'The Old New Thing': https://devblogs.microsoft.com/oldnewthing/20210719-00/?p=105454 ...
Help me solve this puzzle: In the following code I have an std::variant which forward declares a struct proxy which derives from this variant. This st ...
I want to be able to initialize container with a brace init list and not have to specify types. This is more difficult as I have nested initializers. ...