Linked Questions

2 votes
1 answer
1k views

Is the comma (,) a sequence point in std::initializer_list? example: is this UB or not: #include <vector> int main() { auto nums = [] { static unsigned x = 2; return ( ...
Kiril Kirov's user avatar
  • 38.5k
0 votes
0 answers
124 views

I am not sure if a comma in an array initializer is actually a sequence point. Has the statement below defined behavior? The standard does not discuss side-effects during aggregate initialization ...
Bharat Ahuja's user avatar
303 votes
7 answers
20k views

Is it possible for C++ code to conform to both the C++03 standard and the C++11 standard, but do different things depending on under which standard it is being compiled?
Erik Sjölund's user avatar
17 votes
3 answers
1k views

Edit: Not already answered - the linked question was about ordinary r-values, initializer lists are a separate, if related concept. Is this statement well-defined, or is using the prefix increment ...
Ray Hamel's user avatar
  • 1,319
2 votes
3 answers
2k views

Here's the sample code: X * makeX(int index) { return new X(index); } struct Tmp { mutable int count; Tmp() : count(0) {} const X ** getX() const { static const X* x[] = { makeX(...
xryl669's user avatar
  • 3,682
5 votes
2 answers
2k views

I -believe- that what I'm trying to do is probably valid because it is separated in both instances by a comma (not a typical assignment), but I have no idea for sure and search isn't bringing up ...
Simca's user avatar
  • 69
7 votes
2 answers
417 views

I developed many years in C and only now discovered that a program can execute code prior to main() function. Here is a code example int generateNum(){ // Some malicious code here... return 5;...
DanielHsH's user avatar
  • 4,473
10 votes
1 answer
419 views

In the code below is it required that f1 be called before f2 (or vice-versa) or is it unspecified? int f1(); int f2(); std::initializer_list<int> list { f1(), f2() };
linus linus's user avatar
5 votes
1 answer
585 views

Consider the following code: int main() { int count = 0 ; int arrInt[2] = { count++, count++ } ; return 0 ; } If we compile the code using clang -std=c++03 it produces the following ...
Shafik Yaghmour's user avatar
0 votes
1 answer
317 views

I want to find all objects of given types and add them to vector. For now I have code: template<class T> void fill1(std::vector<Character*> &vec2) { for (int i = 0; i < ...
Radosław Panuszewski's user avatar
2 votes
2 answers
134 views

Below code snippet is From Herb Sutter's blog here g++ outputs 10. MSVC also does output 10. Output could be different on different compilers. I fail to understand how variable i is incremented. ...
user1's user avatar
  • 4,151