One additional comment, there is no reason that the implementation of
operator<< couldn't itself use cprintf.  e.g.:

iostream &
operator<<(iostream &out, const Foo &foo)
{
    ccprintf(out, "<%d:%s>", foo.val, foo.name());
    return out;
}

On Fri, Oct 22, 2010 at 2:29 PM, nathan binkert <[email protected]> wrote:
>> Nilay, I apologize for the confusion here.  It seems that Nate and I are 
>> suggesting you go in two different directions in terms of the operator<<.  I 
>> personally wanted to get away from the operator<< overloading, so that Ruby 
>> objects looked more similar to most M5 objects.  Especially because most of 
>> these operator<< functions aren't very useful.
>>
>> Nate, could you elaborate why you'd prefer the operator<< functions versus 
>> the print functions?  My motivation for removing the operator<< functions 
>> was to improve our consistency, but if you have a better reason for removing 
>> the print functions instead, I'm willing to change my mind.
>
> As Steve said, at the bottom of cprintf/DPRINTF, the system uses
> operator<<, so if you use %s, it can handle printing it.  For example.
>  If you had an object Foo that overloaded operator<< and an instance
> foo of that object, you could simply do
> DPRINTF(Flag, "%s", foo)
>
> Instead of what's happening with what you have now of doing:
> DPRINTF(Flag, "%s", foo.print_str());
>
> Furthermore, the printing will be a lot faster with operator<< and
> it's more versatile.
>
> In my opinion, print/print_str should both be gotten rid of and
> operator<< should be what we use.
>
> In short.  operator<< is good.  Using it with cout is bad.
>
> Make sense?
>
>  Nate
>
_______________________________________________
m5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/m5-dev

Reply via email to