Sha256: 4e4d2181b69a7126a98e01b22e5b2ae5485378bb492906edca0635e8f9bcc9eb

Contents?: true

Size: 1.75 KB

Versions: 26

Compression:

Stored size: 1.75 KB

Contents

/* boost random/vector_io.hpp header file
 *
 * Copyright Steven Watanabe 2011
 * Distributed under 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 for most recent version including documentation.
 *
 * $Id$
 */

#ifndef BOOST_RANDOM_DETAIL_VECTOR_IO_HPP
#define BOOST_RANDOM_DETAIL_VECTOR_IO_HPP

#include <vector>
#include <iosfwd>
#include <istream>
#include <boost/io/ios_state.hpp>

namespace boost {
namespace random {
namespace detail {

template<class CharT, class Traits, class T>
void print_vector(std::basic_ostream<CharT, Traits>& os,
                  const std::vector<T>& vec)
{
    typename std::vector<T>::const_iterator
        iter = vec.begin(),
        end =  vec.end();
    os << os.widen('[');
    if(iter != end) {
        os << *iter;
        ++iter;
        for(; iter != end; ++iter)
        {
            os << os.widen(' ') << *iter;
        }
    }
    os << os.widen(']');
}

template<class CharT, class Traits, class T>
void read_vector(std::basic_istream<CharT, Traits>& is, std::vector<T>& vec)
{
    CharT ch;
    if(!(is >> ch)) {
        return;
    }
    if(ch != is.widen('[')) {
        is.putback(ch);
        is.setstate(std::ios_base::failbit);
        return;
    }
    boost::io::basic_ios_exception_saver<CharT, Traits> e(is, std::ios_base::goodbit);
    T val;
    while(is >> std::ws >> val) {
        vec.push_back(val);
    }
    if(is.fail()) {
        is.clear();
        e.restore();
        if(!(is >> ch)) {
            return;
        }
        if(ch != is.widen(']')) {
            is.putback(ch);
            is.setstate(std::ios_base::failbit);
        }
    }
}

}
}
}

#endif // BOOST_RANDOM_DETAIL_VECTOR_IO_HPP

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
passenger-6.0.23 src/cxx_supportlib/vendor-modified/boost/random/detail/vector_io.hpp
passenger-6.0.20 src/cxx_supportlib/vendor-modified/boost/random/detail/vector_io.hpp
passenger-6.0.19 src/cxx_supportlib/vendor-modified/boost/random/detail/vector_io.hpp
passenger-6.0.18 src/cxx_supportlib/vendor-modified/boost/random/detail/vector_io.hpp
passenger-6.0.17 src/cxx_supportlib/vendor-modified/boost/random/detail/vector_io.hpp
passenger-6.0.16 src/cxx_supportlib/vendor-modified/boost/random/detail/vector_io.hpp
passenger-6.0.15 src/cxx_supportlib/vendor-modified/boost/random/detail/vector_io.hpp
passenger-6.0.14 src/cxx_supportlib/vendor-modified/boost/random/detail/vector_io.hpp
passenger-6.0.13 src/cxx_supportlib/vendor-modified/boost/random/detail/vector_io.hpp
passenger-6.0.12 src/cxx_supportlib/vendor-modified/boost/random/detail/vector_io.hpp
passenger-6.0.11 src/cxx_supportlib/vendor-modified/boost/random/detail/vector_io.hpp
passenger-6.0.10 src/cxx_supportlib/vendor-modified/boost/random/detail/vector_io.hpp
passenger-6.0.9 src/cxx_supportlib/vendor-modified/boost/random/detail/vector_io.hpp
passenger-6.0.8 src/cxx_supportlib/vendor-modified/boost/random/detail/vector_io.hpp
passenger-6.0.7 src/cxx_supportlib/vendor-modified/boost/random/detail/vector_io.hpp
passenger-6.0.6 src/cxx_supportlib/vendor-modified/boost/random/detail/vector_io.hpp
passenger-6.0.5 src/cxx_supportlib/vendor-modified/boost/random/detail/vector_io.hpp
passenger-6.0.4 src/cxx_supportlib/vendor-modified/boost/random/detail/vector_io.hpp
passenger-6.0.3 src/cxx_supportlib/vendor-modified/boost/random/detail/vector_io.hpp
passenger-6.0.2 src/cxx_supportlib/vendor-modified/boost/random/detail/vector_io.hpp