Skip to content

Commit 3229d2a

Browse files
committed
Merge pull request cpp-netlib#446 from lyytinen/0.11-devel-fix-for-419
Fix for issue cpp-netlib#419
2 parents 03b34d6 + 36cf176 commit 3229d2a

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

boost/network/protocol/http/algorithms/linearize.hpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define BOOST_NETWORK_PROTOCOL_HTTP_ALGORITHMS_LINEARIZE_HPP_20101028
33

44
// Copyright 2010 Dean Michael Berris.
5+
// Copyright 2014 Jussi Lyytinen
56
// Distributed under the Boost Software License, Version 1.0.
67
// (See accompanying file LICENSE_1_0.txt or copy at
78
// http://www.boost.org/LICENSE_1_0.txt)
@@ -18,6 +19,7 @@
1819
#include <boost/optional.hpp>
1920
#include <boost/range/algorithm/copy.hpp>
2021
#include <boost/algorithm/string/compare.hpp>
22+
#include <boost/version.hpp>
2123

2224
namespace boost {
2325
namespace network {
@@ -137,7 +139,12 @@ BOOST_CONCEPT_REQUIRES(((ClientRequest<Request>)), (OutputIterator))
137139
*oi = consts::colon_char();
138140
*oi = consts::space_char();
139141
boost::copy(request.host(), oi);
140-
boost::optional<boost::uint16_t> port_ = port(request);
142+
boost::optional<boost::uint16_t> port_ =
143+
#if (_MSC_VER >= 1600 && BOOST_VERSION > 105500)
144+
port(request).as_optional();
145+
#else
146+
port(request);
147+
#endif
141148
if (port_) {
142149
string_type port_str = boost::lexical_cast<string_type>(*port_);
143150
*oi = consts::colon_char();

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

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44
// Copyright 2010, 2014 Dean Michael Berris <dberris@google.com>
55
// Copyright 2010 (c) Sinefunc, Inc.
66
// Copyright 2014 Google, Inc.
7+
// Copyright 2014 Jussi Lyytinen
78
// Distributed under the Boost Software License, Version 1.0.
89
// (See accompanying file LICENSE_1_0.txt or copy at
910
// http://www.boost.org/LICENSE_1_0.txt)
1011

1112
#include <boost/optional.hpp>
1213
#include <boost/cstdint.hpp>
1314
#include <boost/network/uri/accessors.hpp>
15+
#include <boost/version.hpp>
1416

1517
namespace boost {
1618
namespace network {
@@ -31,24 +33,19 @@ struct port_wrapper {
3133

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

34-
#if (_MSC_VER >= 1600)
35-
// We hack this so that we don't run into the issue of MSVC 2010 not doing the
36-
// right thing when converting/copying Boost.Optional objects.
37-
struct optional_wrapper {
38-
boost::optional<boost::uint16_t> o_;
39-
explicit optional_wrapper(boost::optional<boost::uint16_t> o) : o_(o) {}
40-
operator boost::optional<boost::uint16_t>() const { return o_; }
41-
};
42-
43-
operator optional_wrapper() const {
44-
return optional_wrapper(uri::port_us(message_.uri()));
36+
#if (_MSC_VER >= 1600 && BOOST_VERSION > 105500)
37+
// Because of a breaking change in Boost 1.56 to boost::optional, implicit
38+
// conversions no longer work correctly with MSVC. The conversion therefore
39+
// has to be done explicitly with as_optional().
40+
boost::optional<boost::uint16_t> as_optional() const {
41+
return uri::port_us(message_.uri());
4542
}
4643
#else
4744
operator boost::optional<boost::uint16_t>() const {
4845
return uri::port_us(message_.uri());
4946
}
5047
#endif
51-
48+
5249
};
5350

5451
} // namespace impl

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy