[prev in list] [next in list] [prev in thread] [next in thread] 

List:       boost-users
Subject:    Re: [Boost-users] Streaming boost::optional yields inconsistent
From:       "Peter Dimov" <pdimov () mmltd ! net>
Date:       2004-02-24 12:09:17
Message-ID: 009001c3facf$07f3fa70$1d00a8c0 () pdimov2
[Download RAW message or body]

Eelis van der Weegen wrote:
> Hi,
> 
> I defined the following operator to stream optional<char>'s:
> 
>    std::ostream &
>      operator<< (std::ostream & os, boost::optional<char> const & op)
>    {
>      if (op) os << *op; else os << '_';
>      return os;
>    }
> 
> Now, when I use:
> 
>    boost::optional<char> a ('a');
>    std::cout << a;
> 
> 'a' is printed like I expected. However, when I use:
> 
>    std::ostream_iterator<boost::optional<char> > oi (std::cout);
>    *oi = a;
> 
> '1' is printed and my operator is apparently ignored (I expected
> another 'a'). Is this a gcc (3.2.3) issue or a boost issue?

Neither. Your operator<< definition should be in namespace boost.
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic