C++ istream / ostream equivalent ?

vincent picaud vincent.picaud at laposte.net
Wed Dec 1 07:51:32 PST 2010


Is there a canonical way to take into account a new type for I/O using the std phobos library ?

To be clear I do not know how to translate something like this (in C++)  in D :

#include <iostream>

class A {};

std::ostream& operator<<(std::ostream& out,const A& a)
{
  out << "\nscreen output routine here\n";
  return out;
}

int main()
{
  A a;
  std::cout << a;
}

Do I have to overload some writeln functions ?

any help is welcome :)


More information about the Digitalmars-d-learn mailing list