From 47557ea5f60bb8ad77aac413eecd7aeb48c8579a Mon Sep 17 00:00:00 2001 From: "Joshua Moerman (@Kassalade)" Date: Sun, 22 May 2011 17:41:27 +0200 Subject: [PATCH] docs --- README | 4 ++-- binary_output/README | 7 +++++++ brainfuck/README | 2 ++ iterators/README | 22 ++++++++++++++++++++++ 4 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 binary_output/README create mode 100644 iterators/README diff --git a/README b/README index b82b417..9e3eca4 100644 --- a/README +++ b/README @@ -1,5 +1,5 @@ -Here are some (hopefully useful) c++ snippets. +Here are some (hopefully useful) c++ snippets/libs/helperthingies. Probably all are header only, with a main.cpp for testing. - +Stuff probably needs some C++0x features. diff --git a/binary_output/README b/binary_output/README new file mode 100644 index 0000000..aab17cc --- /dev/null +++ b/binary_output/README @@ -0,0 +1,7 @@ +Usage: + +std::cout << make_binary(1337) << make_binary("a c-style array"); +will output binary representations of shizzle. + +Make sure your type is copyable by just copying it's memory-region. + diff --git a/brainfuck/README b/brainfuck/README index 1c0ac41..12a47eb 100644 --- a/brainfuck/README +++ b/brainfuck/README @@ -19,3 +19,5 @@ As long as the type has certain operators. The default output is comma-seperated You can specify an output-iterator: brainfuck("...", "", std::back_inserter(my_vector)); + +It has a lot of defaultparameters, because it's intended use was on an irc-channel. diff --git a/iterators/README b/iterators/README new file mode 100644 index 0000000..ca909a6 --- /dev/null +++ b/iterators/README @@ -0,0 +1,22 @@ +counted +======= + +"for(auto x : counted(v)) { ... x.value ... x.index ... }" +x.value is a reference to the element in the container (so you can change it's value), x.index is what it is. +Container should have forward iterators. + + +This headers is purely a handy tool for the range-based-for-loops (ie "for(auto x : counter(v))"). Using it explicitly with iterators is not recommended! + + +There is no const version of it. Doing "for(const auto x : counted(v))" doesn't make it impossible to change x (so the element in the container can be modified). + + +Example: +for(auto x : counted(v)) { + std::cout << "v[" << x.index << "] = " << x.value << std::endl; + x.value *= 2; +} + +This will output the container v, with it's indeces. And it will multiply every value in v by 2. +