Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from1 commit
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
NextNext commit
Fix for issue#419
  • Loading branch information
Jussi Lyytinen committedSep 16, 2014
commit5368f8989a79a189eff8d778092b6bd556fb5ea4
3 changes: 2 additions & 1 deletionboost/network/protocol/http/algorithms/linearize.hpp
View file
Open in desktop
Original file line numberDiff line numberDiff 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 DownExpand Up@@ -137,7 +138,7 @@ 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_ = port(request).as_optional();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This one in particular you may want to wrap in something like this:

boost::optional<boost::uint16_t> port_ =#if (_MSC_VER >= 1600)  port(port).as_optional();#else  port(port);#endif

if (port_) {
string_type port_str = boost::lexical_cast<string_type>(*port_);
*oi = consts::colon_char();
Expand Down
24 changes: 11 additions & 13 deletionsboost/network/protocol/http/message/wrappers/port.hpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,6 +4,7 @@
// 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)
Expand DownExpand Up@@ -31,23 +32,20 @@ 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()));
}
#else
#if !defined(_MSC_VER)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I'm not quite sure this is what we want. Checking that the version is above a certain threshold would be preferred, in my opinion. Something like:

#if (_MSC_VER >= 1600 && BOOST_VERSION >= ...)  // code for the MSVC 2010+ versions and Boost 1.56.0#else  // the normal non-broken conversion operator#endif

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Let's do that then. I deliberately did it this way though so that users would have the option not to use conditional directives in their code and instead just use the explicit conversion.

// 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(). This method is here just
// to maintain backwards compatibility with compilers not affected by the
// change.
operator boost::optional<boost::uint16_t>() const {
return uri::port_us(message_.uri());
}
#endif

boost::optional<boost::uint16_t> as_optional() const {
return uri::port_us(message_.uri());
}

};

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp