Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating pair object c++

Tags:

c++

Why it's not possible to create a pair object in the following way:

pair<int,int> p1 = {0,42}
like image 792
user1602564 Avatar asked Mar 25 '26 16:03

user1602564


1 Answers

in C++03 you should use

std::make_pair(0, 42);

since pair is not simple data-structure. or by calling constructor of pair i.e.

std::pair<int, int> p1(0, 42);

in C++11

pair<int, int> p1 = {0, 42}

is okay.

like image 134
ForEveR Avatar answered Mar 28 '26 06:03

ForEveR