orlyatomics/orly — pull request #129 by mpark (2014-06-20 10:23:55+00:00)
Title: Removed uses of gcc internal, std::_Tuple_impl and updated Base::Join.

Lots of clean-up.

#### Util::ForEach(Tuple, UnaryFn)
__Don't need index, pass a lambda.__
```
std::tuple tuple(0, "begin");
std::istringstream strm("1 end");
ForEach(tuple, [](const auto &elem) { std::cout << elem << std::endl; });
ForEach(tuple, [&strm](auto &elem) { strm >> elem; });
ForEach(tuple, [](const auto &elem) { std::cout << elem << std::endl; });
```
Prints:
```
0
begin
1
end
```
__Need the index, pass a functor.__
```
struct TPrint {

explicit TPrint(std::ostream &strm) : Strm(strm) {}

template
void operator()(const TElem &elem) const {
(I ? Strm << ", " : Strm) << elem;
}

private:

std::ostream &Strm;

}; // TPrint

ForEach(tuple, TPrint(std::cout));
```
Prints: `1, end`

#### Base::Join(Container, Delimiter, Format?)
```
auto tuple = std::make_tuple(42, 1.1, "hello");
std::cout << Base::Join(tuple,
", ",
[](std::ostream &strm, const auto &elem) {
strm << '(' << elem << ')';
}) << std::endl;
```
Prints: `(42), (1.1), (hello)`

If `Format` function is not provided, it defaults to: `[](auto &strm, const auto &elem) { strm << elem; }`

#### Base::AsStr(Arg)
Back to being a one argument function. If you're looking for the variadic version, use the `std::tuple` specialization for `Join`.

Example:
```
std::string text = AsStr(Join(std::forward_as_tuple(42, 1.1, "hello"),
' ',
[](std::ostream &strm, const auto &elem) {
strm << '[' << elem << ']';
});
std::cout << text << std::endl;
```
Prints: `[42] [1.1] [hello]`