Skip to content

Fix for issue #419 #446

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 19, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion boost/network/protocol/http/algorithms/linearize.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define BOOST_NETWORK_PROTOCOL_HTTP_ALGORITHMS_LINEARIZE_HPP_20101028

// Copyright 2010 Dean Michael Berris.
// Copyright 2014 Jussi Lyytinen
// 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)
Expand All @@ -18,6 +19,7 @@
#include <boost/optional.hpp>
#include <boost/range/algorithm/copy.hpp>
#include <boost/algorithm/string/compare.hpp>
#include <boost/version.hpp>

namespace boost {
namespace network {
Expand Down Expand Up @@ -137,7 +139,12 @@ BOOST_CONCEPT_REQUIRES(((ClientRequest<Request>)), (OutputIterator))
*oi = consts::colon_char();
*oi = consts::space_char();
boost::copy(request.host(), oi);
boost::optional<boost::uint16_t> port_ = port(request);
boost::optional<boost::uint16_t> port_ =
#if (_MSC_VER >= 1600 && BOOST_VERSION > 105500)
port(request).as_optional();
#else
port(request);
#endif
if (port_) {
string_type port_str = boost::lexical_cast<string_type>(*port_);
*oi = consts::colon_char();
Expand Down
21 changes: 9 additions & 12 deletions boost/network/protocol/http/message/wrappers/port.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
// Copyright 2010, 2014 Dean Michael Berris <dberris@google.com>
// Copyright 2010 (c) Sinefunc, Inc.
// Copyright 2014 Google, Inc.
// Copyright 2014 Jussi Lyytinen
// 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)

#include <boost/optional.hpp>
#include <boost/cstdint.hpp>
#include <boost/network/uri/accessors.hpp>
#include <boost/version.hpp>

namespace boost {
namespace network {
Expand All @@ -31,24 +33,19 @@ struct port_wrapper {

operator port_type() const { return message_.port(); }

#if (_MSC_VER >= 1600)
// We hack this so that we don't run into the issue of MSVC 2010 not doing the
// right thing when converting/copying Boost.Optional objects.
struct optional_wrapper {
boost::optional<boost::uint16_t> o_;
explicit optional_wrapper(boost::optional<boost::uint16_t> o) : o_(o) {}
operator boost::optional<boost::uint16_t>() const { return o_; }
};

operator optional_wrapper() const {
return optional_wrapper(uri::port_us(message_.uri()));
#if (_MSC_VER >= 1600 && BOOST_VERSION > 105500)
// Because of a breaking change in Boost 1.56 to boost::optional, implicit
// conversions no longer work correctly with MSVC. The conversion therefore
// has to be done explicitly with as_optional().
boost::optional<boost::uint16_t> as_optional() const {
return uri::port_us(message_.uri());
}
#else
operator boost::optional<boost::uint16_t>() const {
return uri::port_us(message_.uri());
}
#endif

};

} // namespace impl
Expand Down