[Boost-bugs] [Boost C++ Libraries] #2103: ostream::operator<<(bool) is called if optional_io.hpp is not included

Subject: [Boost-bugs] [Boost C++ Libraries] #2103: ostream::operator<<(bool) is called if optional_io.hpp is not included
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2008-07-10 10:44:05


#2103: ostream::operator<<(bool) is called if optional_io.hpp is not included
--------------------------+-------------------------------------------------
 Reporter: nasonov | Owner: fcacciola
     Type: Bugs | Status: new
Milestone: Boost 1.36.0 | Component: optional
  Version: Boost 1.35.0 | Severity: Problem
 Keywords: |
--------------------------+-------------------------------------------------
 If you pass an optional<T> value to ostream, it would print a result of
 safe_bool() if <boost/optional/optional_io.hpp> is not included.
 {{{
 $ cat -n unspecified_bool_type.cpp
      1 #include <iostream>
      2 #include <boost/optional/optional.hpp>
      3
      4 boost::optional<char> o('o');
      5
      6 void without_io()
      7 {
      8 std::cout << o << '\n';
      9 }
     10
     11 #include <boost/optional/optional_io.hpp>
     12
     13 void with_io()
     14 {
     15 std::cout << o << '\n';
     16 }
     17
     18 int main()
     19 {
     20 without_io();
     21 with_io();
     22 }
 $ ./a.out
 1
  o
 }}}
 This can be fixed by a adding forward declaration of operator<< to
 optional_fwd.hpp.

 Note that other uses of unspecified_bool_type may be buggy.

-- 
Ticket URL: <http://svn.boost.org/trac/boost/ticket/2103>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:49:58 UTC