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
Fix for issue #419 #446
Fix for issue #419 #446
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
|
@@ -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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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:
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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()); | ||
} | ||
|
||
}; | ||
|
||
|
There was a problem hiding this comment.
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: