|
4 | 4 | // Copyright 2010, 2014 Dean Michael Berris <[email protected]>
|
5 | 5 | // Copyright 2010 (c) Sinefunc, Inc.
|
6 | 6 | // Copyright 2014 Google, Inc.
|
| 7 | +// Copyright 2014 Jussi Lyytinen |
7 | 8 | // Distributed under the Boost Software License, Version 1.0.
|
8 | 9 | // (See accompanying file LICENSE_1_0.txt or copy at
|
9 | 10 | // http://www.boost.org/LICENSE_1_0.txt)
|
@@ -31,23 +32,20 @@ struct port_wrapper {
|
31 | 32 |
|
32 | 33 | operator port_type() const { return message_.port(); }
|
33 | 34 |
|
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())); |
45 |
| - } |
46 |
| -#else |
| 35 | +#if !defined(_MSC_VER) |
| 36 | + // Because of a breaking change in Boost 1.56 to boost::optional, implicit |
| 37 | + // conversions no longer work correctly with MSVC. The conversion therefore |
| 38 | + // has to be done explicitly with as_optional(). This method is here just |
| 39 | + // to maintain backwards compatibility with compilers not affected by the |
| 40 | + // change. |
47 | 41 | operator boost::optional<boost::uint16_t>() const {
|
48 | 42 | return uri::port_us(message_.uri());
|
49 | 43 | }
|
50 | 44 | #endif
|
| 45 | + |
| 46 | + boost::optional<boost::uint16_t> as_optional() const { |
| 47 | + return uri::port_us(message_.uri()); |
| 48 | + } |
51 | 49 |
|
52 | 50 | };
|
53 | 51 |
|
|
0 commit comments