Listing 3: A simple device.
namespace sample {
struct placeholder_1 {};
placeholder_1 _1;
template <typename T> struct simple_binder_lshift {
T& t_;
public:
simple_binder_lshift(T& t):t_(t) {}
template <typename U> T& operator()(U u) {
t_ << u;
return t_;
}
};
}
template <typename T> sample::simple_binder_lshift<T>
operator<<(T& t,sample::placeholder_1 ignore) {
return sample::simple_binder_lshift<T>(t);
}
int main() {
using sample::_1;
std::vector<std::string> vec;
vec.push_back("Simple");
vec.push_back(" example");
std::for_each(vec.begin(),vec.end(),std::cout << _1);
}