[ create a new paste ] login | about

Link: http://codepad.org/NqXFei2o    [ raw code | output | fork ]

C++, pasted on Jan 27:
#include <cstdlib>
#include <string>
#include <sstream>
#include <iostream>

struct Formatter {
  template<class Field>
  Formatter& operator<<(Field const &f) {
    ss_ << f;
    return *this;
  }
  Formatter& operator<<(std::ios_base& (*manip)(std::ios_base&)) {
    ss_ << manip;
    return *this;
  }
  Formatter& operator<<(std::ios& (*manip)(std::ios&)) {
    ss_ << manip;
    return *this;
  }
  Formatter& operator<<(std::ostream& (*manip)(std::ostream&)) {
    ss_ << manip;
    return *this;
  }

  operator std::string() const { return ss_.str(); }

  std::stringstream ss_;
};

void Reject(const std::string& msg)
{
 std::cout << "Recieved Message: '" << msg << "'" << std::endl;
}

int main()
{
 const char& some_code = 'A';
 const char* some_msg = "Something";

 Reject(Formatter() << std::endl);
}


Output:
1
2
Recieved Message: '
'


Create a new paste based on this one


Comments: