简体   繁体   中英

initialize vector of pair of (bitset,int)

when initializing with

vector<pair< int,bitset<p> > > arr;
arr.push_back(make_pair(x,y));

but I am gettig error:

'pair' cannot appear in a constant-expression

vector<pair< int,bitset<p> > > arr;

how to make a vector of pair of bitset,int?

Seems like "p" here is not constant. I tried the following and it works:

const int p = 16;
vector<pair<int,bitset<p> >> v;
bitset<p> b = 0xfa2;
v.push_back(make_pair(10, b));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM