Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 1 | From 8ea2ee451a1af7c5b5c8f4b36c1f77d44442064d Mon Sep 17 00:00:00 2001 |
| 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Fri, 7 Sep 2018 13:02:35 -0700 |
| 4 | Subject: [PATCH] Fix error: call of overloaded distance is ambiguous |
| 5 | MIME-Version: 1.0 |
| 6 | Content-Type: text/plain; charset=UTF-8 |
| 7 | Content-Transfer-Encoding: 8bit |
| 8 | |
| 9 | The boost::iterators::distance function template is an adapted version |
| 10 | of std::distance for the Boost iterator traversal in 2.68 it has started |
| 11 | to fail with argument dependent lookup and compiler is erroring out |
| 12 | |
| 13 | with |
| 14 | |
| 15 | error: call of overloaded ‘distance' |
| 16 | |
| 17 | boost implementation of distance is protected against being found by ADL |
| 18 | |
| 19 | The way function is called in libdhcp means it will be found via ADL and |
| 20 | all namespaces will be considered which is providing problematic since |
| 21 | its getting it from both std:: and boost:: namespaces |
| 22 | |
| 23 | so let it not rely on ADL by qualifying then calls with std:: namespace |
| 24 | |
| 25 | Upstream-Status: Submitted [https://github.com/isc-projects/kea/pull/103] |
| 26 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 27 | --- |
| 28 | src/lib/dhcp/libdhcp++.cc | 12 ++++++------ |
| 29 | 1 file changed, 6 insertions(+), 6 deletions(-) |
| 30 | |
| 31 | diff --git a/src/lib/dhcp/libdhcp++.cc b/src/lib/dhcp/libdhcp++.cc |
| 32 | index 330c02b..ced705d 100644 |
| 33 | --- a/src/lib/dhcp/libdhcp++.cc |
| 34 | +++ b/src/lib/dhcp/libdhcp++.cc |
| 35 | @@ -419,14 +419,14 @@ size_t LibDHCP::unpackOptions6(const OptionBuffer& buf, |
| 36 | // We previously did the lookup only for dhcp6 option space, but with the |
| 37 | // addition of S46 options, we now do it for every space. |
| 38 | range = idx.equal_range(opt_type); |
| 39 | - num_defs = distance(range.first, range.second); |
| 40 | + num_defs = std::distance(range.first, range.second); |
| 41 | |
| 42 | // Standard option definitions do not include the definition for |
| 43 | // our option or we're searching for non-standard option. Try to |
| 44 | // find the definition among runtime option definitions. |
| 45 | if (num_defs == 0) { |
| 46 | range = runtime_idx.equal_range(opt_type); |
| 47 | - num_defs = distance(range.first, range.second); |
| 48 | + num_defs = std::distance(range.first, range.second); |
| 49 | } |
| 50 | |
| 51 | OptionPtr opt; |
| 52 | @@ -538,14 +538,14 @@ size_t LibDHCP::unpackOptions4(const OptionBuffer& buf, |
| 53 | // may be standard options in other spaces (e.g. radius). So we now do |
| 54 | // the lookup for every space. |
| 55 | range = idx.equal_range(opt_type); |
| 56 | - num_defs = distance(range.first, range.second); |
| 57 | + num_defs = std::distance(range.first, range.second); |
| 58 | |
| 59 | // Standard option definitions do not include the definition for |
| 60 | // our option or we're searching for non-standard option. Try to |
| 61 | // find the definition among runtime option definitions. |
| 62 | if (num_defs == 0) { |
| 63 | range = runtime_idx.equal_range(opt_type); |
| 64 | - num_defs = distance(range.first, range.second); |
| 65 | + num_defs = std::distance(range.first, range.second); |
| 66 | } |
| 67 | |
| 68 | // Check if option unpacking must be deferred |
| 69 | @@ -638,7 +638,7 @@ size_t LibDHCP::unpackVendorOptions6(const uint32_t vendor_id, |
| 70 | idx->equal_range(opt_type); |
| 71 | // Get the number of returned option definitions for the |
| 72 | // option code. |
| 73 | - size_t num_defs = distance(range.first, range.second); |
| 74 | + size_t num_defs = std::distance(range.first, range.second); |
| 75 | |
| 76 | if (num_defs > 1) { |
| 77 | // Multiple options of the same code are not supported |
| 78 | @@ -746,7 +746,7 @@ size_t LibDHCP::unpackVendorOptions4(const uint32_t vendor_id, const OptionBuffe |
| 79 | idx->equal_range(opt_type); |
| 80 | // Get the number of returned option definitions for |
| 81 | // the option code. |
| 82 | - size_t num_defs = distance(range.first, range.second); |
| 83 | + size_t num_defs = std::distance(range.first, range.second); |
| 84 | |
| 85 | if (num_defs > 1) { |
| 86 | // Multiple options of the same code are not |
| 87 | -- |
| 88 | 2.18.0 |
| 89 | |