1//
2// ip/impl/address.hpp
3// ~~~~~~~~~~~~~~~~~~~
4//
5// Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6//
7// Distributed under the Boost Software License, Version 1.0. (See accompanying
8// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9//
10
11#ifndef BOOST_ASIO_IP_IMPL_ADDRESS_HPP
12#define BOOST_ASIO_IP_IMPL_ADDRESS_HPP
13
14#if defined(_MSC_VER) && (_MSC_VER >= 1200)
15# pragma once
16#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17
18#if !defined(BOOST_ASIO_NO_IOSTREAM)
19
20#include <boost/asio/detail/throw_error.hpp>
21
22#include <boost/asio/detail/push_options.hpp>
23
24namespace boost {
25namespace asio {
26namespace ip {
27
28template <typename Elem, typename Traits>
29std::basic_ostream<Elem, Traits>& operator<<(
30 std::basic_ostream<Elem, Traits>& os, const address& addr)
31{
32 boost::system::error_code ec;
33 std::string s = addr.to_string(ec);
34 if (ec)
35 {
36 if (os.exceptions() & std::basic_ostream<Elem, Traits>::failbit)
37 boost::asio::detail::throw_error(err: ec);
38 else
39 os.setstate(std::basic_ostream<Elem, Traits>::failbit);
40 }
41 else
42 for (std::string::iterator i = s.begin(); i != s.end(); ++i)
43 os << os.widen(*i);
44 return os;
45}
46
47} // namespace ip
48} // namespace asio
49} // namespace boost
50
51#include <boost/asio/detail/pop_options.hpp>
52
53#endif // !defined(BOOST_ASIO_NO_IOSTREAM)
54
55#endif // BOOST_ASIO_IP_IMPL_ADDRESS_HPP
56

source code of boost/boost/asio/ip/impl/address.hpp