Skip to content

Commit 7b88441

Browse files
committed
ADL lookup for operator<< working with std::ostream
This commit allows for easier output of the body contained in a message object.
1 parent 8434182 commit 7b88441

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

boost/network/message/wrappers/body.hpp

+12
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,18 @@ namespace boost { namespace network {
7777
return boost::make_iterator_range(wrapper_base::_message.body());
7878
}
7979
};
80+
81+
template <class Tag>
82+
inline std::ostream & operator<<(std::ostream & os, body_wrapper<Tag> const & body) {
83+
os << static_cast<typename body_wrapper<Tag>::string_type>(body);
84+
return os;
85+
}
86+
87+
template <class Tag>
88+
inline std::ostream & operator<<(std::ostream & os, body_wrapper_const<Tag> const & body) {
89+
os << static_cast<typename body_wrapper_const<Tag>::string_type>(body);
90+
return os;
91+
}
8092

8193
} // namespace impl
8294

boost/network/protocol/http/message/wrappers/body.hpp

+6
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ namespace boost { namespace network { namespace http {
3939
return boost::make_iterator_range(message_.body());
4040
}
4141
};
42+
43+
template <class Message>
44+
inline std::ostream & operator<<(std::ostream & os, body_wrapper<Message> const & body) {
45+
os << static_cast<typename body_wrapper<Message>::string_type>(body);
46+
return os;
47+
}
4248

4349
} // namespace impl
4450

0 commit comments

Comments
 (0)