cpp_libraries | article |
---|---|
cpp_binarysearch | http://qiita.com/cielavenir/items/852e2458cd327ca73613 |
cpp_inspect | http://qiita.com/cielavenir/items/95615185b5ca47d9111d |
cpp_range | http://qiita.com/cielavenir/items/94c9abbb7767bd57607b |
cpp_rational | http://qiita.com/cielavenir/items/2171327462d2afd98b65 |
Download
What's this?
You can print the content of C++ STL container and use it as C++11 uniform initialization.
Example
# include "inspect.hpp"
int main(){
std::map<std::pair<int,std::string>,std::vector<std::array<int,3>>> val=
{
{{1,"2"},{
{{1,2,3}},
{{4,5,6}},
}},
{{4,"5"},{
{{4,5,6}},
{{7,8,9}},
}},
{{7,"8"},{
{{7,8,9}},
{{1,2,3}},
}},
};
std::cout<<val<<std::endl;
}
Note std::cout<<val<<std::endl
is not usually possible, because ostream operator<<(std::map<T,S>&)
is not defined.
When you execute this program, you can get:
{{{1,"2"},{{{1,2,3,}},{{4,5,6,}},}},{{4,"5"},{{{4,5,6,}},{{7,8,9,}},}},{{7,"8"},{{{7,8,9,}},{{1,2,3,}},}},}
which you can confirm to be the same as the original declaration.