Skip to content

Update boost to std #589

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

Merged
merged 15 commits into from
Jan 30, 2016
Merged
Show file tree
Hide file tree
Changes from 1 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
Prev Previous commit
Next Next commit
Replace boost::unordered containers with std.
  • Loading branch information
glynos committed Jan 29, 2016
commit 77c08ab3848e4b7e699bb15cbdecfe8f4048f901
4 changes: 2 additions & 2 deletions boost/network/protocol/http/policies/async_resolver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
// http://www.boost.org/LICENSE_1_0.txt)

#include <memory>
#include <unordered_map>
#include <boost/asio/placeholders.hpp>
#include <boost/asio/strand.hpp>
#include <boost/network/protocol/http/traits/resolver.hpp>
#include <boost/network/traits/string.hpp>
#include <boost/unordered/unordered_map.hpp>
#include <boost/function.hpp>
#include <boost/algorithm/string/case_conv.hpp>
#include <boost/lexical_cast.hpp>
Expand All @@ -31,7 +31,7 @@ struct async_resolver : std::enable_shared_from_this<async_resolver<Tag> > {
typedef std::pair<resolver_iterator, resolver_iterator>
resolver_iterator_pair;
typedef typename string<Tag>::type string_type;
typedef boost::unordered_map<string_type, resolver_iterator_pair>
typedef std::unordered_map<string_type, resolver_iterator_pair>
endpoint_cache;
typedef boost::function<
void(boost::system::error_code const &, resolver_iterator_pair)>
Expand Down
4 changes: 2 additions & 2 deletions boost/network/protocol/http/policies/pooled_connection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
// http://www.boost.org/LICENSE_1_0.txt)

#include <mutex>
#include <unordered_map>
#include <boost/algorithm/string/predicate.hpp>
#include <boost/network/protocol/http/client/connection/sync_base.hpp>
#include <boost/network/protocol/http/response.hpp>
#include <boost/network/protocol/http/traits/resolver_policy.hpp>
#include <boost/unordered_map.hpp>
#include <utility>

#ifndef BOOST_NETWORK_HTTP_MAXIMUM_REDIRECT_COUNT
Expand Down Expand Up @@ -180,7 +180,7 @@ struct pooled_connection_policy : resolver_policy<Tag>::type {

typedef std::shared_ptr<connection_impl> connection_ptr;

typedef unordered_map<string_type, std::weak_ptr<connection_impl>> host_connection_map;
typedef std::unordered_map<string_type, std::weak_ptr<connection_impl>> host_connection_map;
std::mutex host_mutex_;
host_connection_map host_connections_;
bool follow_redirect_;
Expand Down
4 changes: 2 additions & 2 deletions boost/network/protocol/http/policies/sync_resolver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

#include <unordered_map>
#include <boost/network/protocol/http/traits/resolver.hpp>
#include <utility>
#include <boost/fusion/adapted/std_pair.hpp>
#include <boost/fusion/include/tuple.hpp>
#include <boost/algorithm/string/case_conv.hpp>
#include <boost/network/traits/string.hpp>
#include <boost/unordered_map.hpp>

namespace boost {
namespace network {
Expand All @@ -30,7 +30,7 @@ struct sync_resolver {

protected:
typedef typename string<Tag>::type string_type;
typedef boost::unordered_map<string_type, resolver_iterator_pair>
typedef std::unordered_map<string_type, resolver_iterator_pair>
resolved_cache;
resolved_cache endpoint_cache_;
bool cache_resolved_;
Expand Down
23 changes: 23 additions & 0 deletions boost/network/uri/uri.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#pragma once

#include <iterator>
#include <functional>
#include <boost/network/uri/config.hpp>
#include <boost/network/uri/detail/uri_parts.hpp>
#include <boost/network/uri/schemes.hpp>
Expand Down Expand Up @@ -297,7 +298,29 @@ inline std::size_t hash_value(const uri &uri_) {
}
return seed;
}
} // namespace uri
} // namespace network
} // namespace boost

namespace std {
template <>
struct hash<boost::network::uri::uri> {

std::size_t operator()(const boost::network::uri::uri &uri_) const {
std::size_t seed = 0;
std::for_each(std::begin(uri_), std::end(uri_),
[&seed](boost::network::uri::uri::value_type v) {
std::hash<boost::network::uri::uri::value_type> hasher;
seed ^= hasher(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
});
return seed;
}
};
} // namespace std

namespace boost {
namespace network {
namespace uri {
inline bool operator==(const uri &lhs, const uri &rhs) {
return boost::equal(lhs, rhs);
}
Expand Down
6 changes: 3 additions & 3 deletions libs/network/src/uri/schemes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

#include <unordered_set>
#include <boost/network/uri/schemes.hpp>
#include <boost/unordered_set.hpp>

namespace boost {
namespace network {
namespace uri {
namespace {
static boost::unordered_set<std::string> hierarchical_schemes_;
static boost::unordered_set<std::string> opaque_schemes_;
static std::unordered_set<std::string> hierarchical_schemes_;
static std::unordered_set<std::string> opaque_schemes_;

bool register_hierarchical_schemes() {
hierarchical_schemes_.insert("http");
Expand Down
4 changes: 2 additions & 2 deletions libs/network/test/uri/uri_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include <memory>
#include <map>
#include <set>
#include <boost/unordered_set.hpp>
#include <unordered_set>

using namespace boost::network;

Expand Down Expand Up @@ -530,7 +530,7 @@ TEST(URITest, uri_set_test) {
}

TEST(URITest, uri_unordered_set_test) {
boost::unordered_set<uri::uri> uri_set;
std::unordered_set<uri::uri> uri_set;
uri_set.insert(uri::uri("http://www.example.com/"));
ASSERT_TRUE(!uri_set.empty());
EXPECT_EQ(uri::uri("http://www.example.com/"), (*uri_set.begin()));
Expand Down