[ create a new paste ] login | about

Link: http://codepad.org/BIqNQyea    [ 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;
  }
  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
3
In function 'int main()':
Line 27: error: no match for 'operator<<' in 'Formatter() << std::endl'
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: