Skip to content

Instantly share code, notes, and snippets.

@cjhanks
Created January 21, 2016 20:35
Show Gist options
  • Save cjhanks/8126dc64c785482d6e79 to your computer and use it in GitHub Desktop.
Save cjhanks/8126dc64c785482d6e79 to your computer and use it in GitHub Desktop.
I can trull
#include <cmath>
#include <algorithm>
#include <iostream>
#include <tuple>
#include <vector>
int
main()
{
using namespace std;
vector<tuple<int, int>> data;
size_t i = 0;
generate_n(back_inserter(data),
pow(4, 11),
[&i]() { ++i; return make_tuple(i, i); });
}
@jfinken
Copy link

jfinken commented Jan 21, 2016

Wacky. C++11?

// on my crappy xubuntu vm...
$ g++ troll.cpp -std=gnu++11
$ time ./a.out

real    0m0.836s
user    0m0.739s
sys 0m0.058s

// https://play.golang.org/p/UzxaLemvIj
$ go build main.go
$ time ./slice_of_tuples 
Len of thing: 4194304

real    0m0.103s
user    0m0.059s
sys 0m0.035s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment