Boost logo

Boost Users :

Subject: Re: [Boost-users] RES: How do I print a standard pair?
From: Igor R (boost.lists_at_[hidden])
Date: 2011-09-26 10:08:47

>> In short, you'll have to define a global operator<< for type std::pair<T,
>> U>:
>> template<typename CharType, typename T, typename U>
>> std::basic_ostream<CharType>& operator<< (std::basic_ostream<CharType>& o,
>> std::pair<T, U> mypair)
>> {
>> return o << "This is my way of printing a pair: first: " <<
>> mypair.first  << " and second: " << mypair.second;
>> }
> This is strictly forbidden by the standard AFAIK.

How can the standard forbid defining your own operators?
The standard forbids putting things into std namespace.

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at