Static std::pair in function

Quiz: what are the values of p.first and p.second?

1
2
3
4
5
6
#include <utility>

void f()
{
    static std::pair<int, char> p;
}

0 and 0
http://cplusplus.com/reference/utility/pair/pair/
(1) default constructor
Constructs a pair object with its elements value-initialized.


http://stackoverflow.com/questions/5610629/difference-between-default-initialize-and-value-initialize
To value-initialize an object of type T means:
— if T is a class type (clause 9) with a user-declared constructor (12.1), then the default constructor for T is called (and the initialization is ill-formed if T has no accessible default constructor);
— if T is a non-union class type without a user-declared constructor, then every non-static data member and base-class component of T is value-initialized;96)
— if T is an array type, then each element is value-initialized;
— otherwise, the object is zero-initialized
Last edited on
Thanks you.
oh i thought you know the answer and you just wanted to make a quiz out of this :D
Topic archived. No new replies allowed.