#include <iostream>

void append_to_stream(std::ostream &stream)
{ }

template <typename T, typename... Args>
void append_to_stream(std::ostream &stream, T &&first, Args&&... rest)
{
  stream << std::forward< T >( first );
  append_to_stream(stream, std::forward< Args >( rest ) ...);
}

typedef std::ostream & (&manip_t)( std::ostream & );

int main() {

append_to_stream(std::cout, 
                 "hello world",
                 static_cast< manip_t >( std::endl ),
                 static_cast< manip_t >( std::endl ) );
std::cout << "done\n";
}
