diff --git a/boost/network/protocol/http/algorithms/linearize.hpp b/boost/network/protocol/http/algorithms/linearize.hpp index 4f91cce64..d0347fd04 100644 --- a/boost/network/protocol/http/algorithms/linearize.hpp +++ b/boost/network/protocol/http/algorithms/linearize.hpp @@ -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) @@ -18,6 +19,7 @@ #include #include #include +#include namespace boost { namespace network { @@ -137,7 +139,12 @@ BOOST_CONCEPT_REQUIRES(((ClientRequest)), (OutputIterator)) *oi = consts::colon_char(); *oi = consts::space_char(); boost::copy(request.host(), oi); - boost::optional port_ = port(request); + boost::optional 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(*port_); *oi = consts::colon_char(); diff --git a/boost/network/protocol/http/message/wrappers/port.hpp b/boost/network/protocol/http/message/wrappers/port.hpp index ac00a61c0..f05d9dc81 100644 --- a/boost/network/protocol/http/message/wrappers/port.hpp +++ b/boost/network/protocol/http/message/wrappers/port.hpp @@ -4,6 +4,7 @@ // Copyright 2010, 2014 Dean Michael Berris // 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) @@ -11,6 +12,7 @@ #include #include #include +#include namespace boost { namespace network { @@ -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 o_; - explicit optional_wrapper(boost::optional o) : o_(o) {} - operator boost::optional() 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 as_optional() const { + return uri::port_us(message_.uri()); } #else operator boost::optional() const { return uri::port_us(message_.uri()); } #endif - + }; } // namespace impl