Sha256: b8efe4a25205261d7acdfb3700cd643245097094449c541ad42bc5b47857a4cb

Contents?: true

Size: 1.73 KB

Versions: 47

Compression:

Stored size: 1.73 KB

Contents

// Copyright (C) 2005, Fernando Luis Cacciola Carballal.
//
// Use, modification, and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// See http://www.boost.org/libs/optional for documentation.
//
// You are welcome to contact the author at:
//  fernando_cacciola@hotmail.com
//
#ifndef BOOST_OPTIONAL_OPTIONAL_IO_FLC_19NOV2002_HPP
#define BOOST_OPTIONAL_OPTIONAL_IO_FLC_19NOV2002_HPP

#include <istream>
#include <ostream>

#include "boost/none.hpp"
#include "boost/optional/optional.hpp"


namespace boost
{

template<class CharType, class CharTrait>
inline
std::basic_ostream<CharType, CharTrait>&
operator<<(std::basic_ostream<CharType, CharTrait>& out, none_t)
{
  if (out.good())
  {
    out << "--";
  }
   
  return out;
}

template<class CharType, class CharTrait, class T>
inline
std::basic_ostream<CharType, CharTrait>&
operator<<(std::basic_ostream<CharType, CharTrait>& out, optional<T> const& v)
{
  if (out.good())
  {
    if (!v)
         out << "--" ;
    else out << ' ' << *v ;
  }

  return out;
}

template<class CharType, class CharTrait, class T>
inline
std::basic_istream<CharType, CharTrait>&
operator>>(std::basic_istream<CharType, CharTrait>& in, optional<T>& v)
{
  if (in.good())
  {
    int d = in.get();
    if (d == ' ')
    {
      T x;
      in >> x;
#ifndef  BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
      v = boost::move(x);
#else
      v = x;
#endif
    }
    else
    {
      if (d == '-')
      {
        d = in.get();

        if (d == '-')
        {
          v = none;
          return in;
        }
      }

      in.setstate( std::ios::failbit );
    }
  }

  return in;
}

} // namespace boost

#endif

Version data entries

47 entries across 47 versions & 2 rubygems

Version Path
passenger-6.0.14 src/cxx_supportlib/vendor-modified/boost/optional/optional_io.hpp
passenger-6.0.13 src/cxx_supportlib/vendor-modified/boost/optional/optional_io.hpp
passenger-6.0.12 src/cxx_supportlib/vendor-modified/boost/optional/optional_io.hpp
passenger-6.0.11 src/cxx_supportlib/vendor-modified/boost/optional/optional_io.hpp
passenger-6.0.10 src/cxx_supportlib/vendor-modified/boost/optional/optional_io.hpp
passenger-6.0.9 src/cxx_supportlib/vendor-modified/boost/optional/optional_io.hpp
passenger-6.0.8 src/cxx_supportlib/vendor-modified/boost/optional/optional_io.hpp
passenger-6.0.7 src/cxx_supportlib/vendor-modified/boost/optional/optional_io.hpp
passenger-6.0.6 src/cxx_supportlib/vendor-modified/boost/optional/optional_io.hpp
passenger-6.0.5 src/cxx_supportlib/vendor-modified/boost/optional/optional_io.hpp
passenger-6.0.4 src/cxx_supportlib/vendor-modified/boost/optional/optional_io.hpp
passenger-6.0.3 src/cxx_supportlib/vendor-modified/boost/optional/optional_io.hpp
passenger-6.0.2 src/cxx_supportlib/vendor-modified/boost/optional/optional_io.hpp
passenger-6.0.1 src/cxx_supportlib/vendor-modified/boost/optional/optional_io.hpp
passenger-6.0.0 src/cxx_supportlib/vendor-modified/boost/optional/optional_io.hpp
passenger-5.3.7 src/cxx_supportlib/vendor-modified/boost/optional/optional_io.hpp
passenger-5.3.6 src/cxx_supportlib/vendor-modified/boost/optional/optional_io.hpp
passenger-5.3.5 src/cxx_supportlib/vendor-modified/boost/optional/optional_io.hpp
passenger-5.3.4 src/cxx_supportlib/vendor-modified/boost/optional/optional_io.hpp
passenger-5.3.3 src/cxx_supportlib/vendor-modified/boost/optional/optional_io.hpp