Skip to content

Commit 77c08ab

Browse files
committed
Replace boost::unordered containers with std.
1 parent f4f6a86 commit 77c08ab

File tree

6 files changed

+34
-11
lines changed

6 files changed

+34
-11
lines changed

boost/network/protocol/http/policies/async_resolver.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
// http://www.boost.org/LICENSE_1_0.txt)
88

99
#include <memory>
10+
#include <unordered_map>
1011
#include <boost/asio/placeholders.hpp>
1112
#include <boost/asio/strand.hpp>
1213
#include <boost/network/protocol/http/traits/resolver.hpp>
1314
#include <boost/network/traits/string.hpp>
14-
#include <boost/unordered/unordered_map.hpp>
1515
#include <boost/function.hpp>
1616
#include <boost/algorithm/string/case_conv.hpp>
1717
#include <boost/lexical_cast.hpp>
@@ -31,7 +31,7 @@ struct async_resolver : std::enable_shared_from_this<async_resolver<Tag> > {
3131
typedef std::pair<resolver_iterator, resolver_iterator>
3232
resolver_iterator_pair;
3333
typedef typename string<Tag>::type string_type;
34-
typedef boost::unordered_map<string_type, resolver_iterator_pair>
34+
typedef std::unordered_map<string_type, resolver_iterator_pair>
3535
endpoint_cache;
3636
typedef boost::function<
3737
void(boost::system::error_code const &, resolver_iterator_pair)>

boost/network/protocol/http/policies/pooled_connection.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
// http://www.boost.org/LICENSE_1_0.txt)
99

1010
#include <mutex>
11+
#include <unordered_map>
1112
#include <boost/algorithm/string/predicate.hpp>
1213
#include <boost/network/protocol/http/client/connection/sync_base.hpp>
1314
#include <boost/network/protocol/http/response.hpp>
1415
#include <boost/network/protocol/http/traits/resolver_policy.hpp>
15-
#include <boost/unordered_map.hpp>
1616
#include <utility>
1717

1818
#ifndef BOOST_NETWORK_HTTP_MAXIMUM_REDIRECT_COUNT
@@ -180,7 +180,7 @@ struct pooled_connection_policy : resolver_policy<Tag>::type {
180180

181181
typedef std::shared_ptr<connection_impl> connection_ptr;
182182

183-
typedef unordered_map<string_type, std::weak_ptr<connection_impl>> host_connection_map;
183+
typedef std::unordered_map<string_type, std::weak_ptr<connection_impl>> host_connection_map;
184184
std::mutex host_mutex_;
185185
host_connection_map host_connections_;
186186
bool follow_redirect_;

boost/network/protocol/http/policies/sync_resolver.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
// (See accompanying file LICENSE_1_0.txt or copy at
77
// http://www.boost.org/LICENSE_1_0.txt)
88

9+
#include <unordered_map>
910
#include <boost/network/protocol/http/traits/resolver.hpp>
1011
#include <utility>
1112
#include <boost/fusion/adapted/std_pair.hpp>
1213
#include <boost/fusion/include/tuple.hpp>
1314
#include <boost/algorithm/string/case_conv.hpp>
1415
#include <boost/network/traits/string.hpp>
15-
#include <boost/unordered_map.hpp>
1616

1717
namespace boost {
1818
namespace network {
@@ -30,7 +30,7 @@ struct sync_resolver {
3030

3131
protected:
3232
typedef typename string<Tag>::type string_type;
33-
typedef boost::unordered_map<string_type, resolver_iterator_pair>
33+
typedef std::unordered_map<string_type, resolver_iterator_pair>
3434
resolved_cache;
3535
resolved_cache endpoint_cache_;
3636
bool cache_resolved_;

boost/network/uri/uri.hpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#pragma once
1111

1212
#include <iterator>
13+
#include <functional>
1314
#include <boost/network/uri/config.hpp>
1415
#include <boost/network/uri/detail/uri_parts.hpp>
1516
#include <boost/network/uri/schemes.hpp>
@@ -297,7 +298,29 @@ inline std::size_t hash_value(const uri &uri_) {
297298
}
298299
return seed;
299300
}
301+
} // namespace uri
302+
} // namespace network
303+
} // namespace boost
304+
305+
namespace std {
306+
template <>
307+
struct hash<boost::network::uri::uri> {
308+
309+
std::size_t operator()(const boost::network::uri::uri &uri_) const {
310+
std::size_t seed = 0;
311+
std::for_each(std::begin(uri_), std::end(uri_),
312+
[&seed](boost::network::uri::uri::value_type v) {
313+
std::hash<boost::network::uri::uri::value_type> hasher;
314+
seed ^= hasher(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
315+
});
316+
return seed;
317+
}
318+
};
319+
} // namespace std
300320

321+
namespace boost {
322+
namespace network {
323+
namespace uri {
301324
inline bool operator==(const uri &lhs, const uri &rhs) {
302325
return boost::equal(lhs, rhs);
303326
}

libs/network/src/uri/schemes.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
// (See accompanying file LICENSE_1_0.txt or copy at
44
// http://www.boost.org/LICENSE_1_0.txt)
55

6+
#include <unordered_set>
67
#include <boost/network/uri/schemes.hpp>
7-
#include <boost/unordered_set.hpp>
88

99
namespace boost {
1010
namespace network {
1111
namespace uri {
1212
namespace {
13-
static boost::unordered_set<std::string> hierarchical_schemes_;
14-
static boost::unordered_set<std::string> opaque_schemes_;
13+
static std::unordered_set<std::string> hierarchical_schemes_;
14+
static std::unordered_set<std::string> opaque_schemes_;
1515

1616
bool register_hierarchical_schemes() {
1717
hierarchical_schemes_.insert("http");

libs/network/test/uri/uri_test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include <memory>
1515
#include <map>
1616
#include <set>
17-
#include <boost/unordered_set.hpp>
17+
#include <unordered_set>
1818

1919
using namespace boost::network;
2020

@@ -530,7 +530,7 @@ TEST(URITest, uri_set_test) {
530530
}
531531

532532
TEST(URITest, uri_unordered_set_test) {
533-
boost::unordered_set<uri::uri> uri_set;
533+
std::unordered_set<uri::uri> uri_set;
534534
uri_set.insert(uri::uri("http://www.example.com/"));
535535
ASSERT_TRUE(!uri_set.empty());
536536
EXPECT_EQ(uri::uri("http://www.example.com/"), (*uri_set.begin()));

0 commit comments

Comments
 (0)