Created
June 6, 2011 13:11
-
-
Save louisdx/1010215 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
#include <unordered_map> | |
#include <map> | |
#include <set> | |
#include <array> | |
#include <tuple> | |
#include <utility> | |
#include <string> | |
#include <sstream> | |
#include "prettyprint.hpp" | |
struct MyDel { static const delimiters_values<char> values; }; | |
const delimiters_values<char> MyDel::values = { "<", "; ", ">" }; | |
int main(int argc, char * argv[]) | |
{ | |
std::string cs; | |
std::unordered_map<int, std::string> um; | |
std::map<int, std::string> om; | |
std::set<std::string> ss; | |
std::vector<std::string> v; | |
std::vector<std::vector<std::string>> vv; | |
std::vector<std::pair<int, std::string>> vp; | |
v.reserve(argc - 1); | |
vv.reserve(argc - 1); | |
vp.reserve(argc - 1); | |
std::cout << "Printing pairs." << std::endl; | |
for (int i = 1; i < argc; ++i) | |
{ | |
std::string s(argv[i]); | |
std::pair<int, std::string> p(i, s); | |
um[i] = s; | |
om[i] = s; | |
v.push_back(s); | |
vv.push_back(v); | |
vp.push_back(p); | |
ss.insert(s); | |
cs += s; | |
std::cout << " " << p << std::endl; | |
} | |
std::array<char, 5> a { 'h', 'e', 'l', 'l', 'o' }; | |
std::cout << "Vector: " << v << std::endl | |
<< "Incremental vector: " << vv << std::endl | |
<< "Pairs: " << vp << std::endl | |
<< "Set: " << ss << std::endl | |
<< "OMap: " << om << std::endl | |
<< "UMap: " << um << std::endl | |
<< "String: " << cs << std::endl | |
<< "Array: " << a << std::endl | |
; | |
auto a1 = std::make_pair(std::string("Jello"), 9); | |
auto a2 = std::make_tuple(1729); | |
auto a3 = std::make_tuple("Qrgh", a1, 11); | |
auto a4 = std::make_tuple(1729, 2875, std::pair<double, std::string>(1.5, "abc")); | |
int arr[] = { 1, 4, 9, 16 }; | |
std::cout << print_container_helper<std::vector<std::string>, char, std::char_traits<char>, MyDel>(v) << std::endl; | |
std::cout << "C array: " << wrap_array(arr) << std::endl | |
<< "Pair: " << a1 << std::endl | |
<< "1-tuple: " << a2 << std::endl | |
<< "n-tuple: " << a3 << std::endl | |
; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment