c++ - How to treat std::pair as two separate variables? -
there few functions in standard library, such std::map::insert
, return std::pair
. @ times convenient have populate 2 different variables corresponding halves of pair. there easy way that?
std::map<int,int>::iterator it; bool b; magic(it, b) = mymap.insert(std::make_pair(42, 1));
i'm looking magic
here.
std::tie
<tuple>
header want.
std::tie(it, b) = mymap.insert(std::make_pair(42, 1));
"magic
" :)
note: c++11 feature.
Comments
Post a Comment