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
Replaced boost::array with std::array.
  • Loading branch information
glynos committed Jan 30, 2016
commit 516e1055db604091d0b422d3eefb445aa7e7bf35
12 changes: 7 additions & 5 deletions boost/network/protocol/http/client/connection/async_normal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ struct http_async_connection
}
}
delegate_->read_some(
boost::asio::mutable_buffers_1(this->part.c_array(),
boost::asio::mutable_buffers_1(this->part.data(),
this->part.size()),
request_strand_.wrap(boost::bind(
&this_type::handle_received_data, this_type::shared_from_this(),
Expand Down Expand Up @@ -309,7 +309,8 @@ struct http_async_connection
this->body_promise.set_value("");
this->destination_promise.set_value("");
this->source_promise.set_value("");
this->part.assign('\0');
// this->part.assign('\0');
boost::copy("\0", std::begin(this->part));
this->response_parser_.reset();
return;
}
Expand All @@ -335,7 +336,7 @@ struct http_async_connection
callback(make_iterator_range(begin, end), ec);

delegate_->read_some(
boost::asio::mutable_buffers_1(this->part.c_array(),
boost::asio::mutable_buffers_1(this->part.data(),
this->part.size()),
request_strand_.wrap(boost::bind(
&this_type::handle_received_data,
Expand Down Expand Up @@ -382,7 +383,8 @@ struct http_async_connection
// TODO(dberris): set the destination value somewhere!
this->destination_promise.set_value("");
this->source_promise.set_value("");
this->part.assign('\0');
// this->part.assign('\0');
boost::copy("\0", std::begin(this->part));
this->response_parser_.reset();
this->timer_.cancel();
} else {
Expand All @@ -398,7 +400,7 @@ struct http_async_connection
std::advance(end, bytes_transferred);
callback(make_iterator_range(begin, end), ec);
delegate_->read_some(
boost::asio::mutable_buffers_1(this->part.c_array(),
boost::asio::mutable_buffers_1(this->part.data(),
this->part.size()),
request_strand_.wrap(boost::bind(
&this_type::handle_received_data,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include <iterator>
#include <cstdint>
#include <array>
#include <boost/fusion/tuple/tuple.hpp>
#include <boost/fusion/tuple/tuple_tie.hpp>
#include <boost/logic/tribool.hpp>
Expand Down Expand Up @@ -140,7 +141,7 @@ struct http_async_protocol_handler {
std::end(result_range));
part_begin = part.begin();
delegate_->read_some(
boost::asio::mutable_buffers_1(part.c_array(), part.size()),
boost::asio::mutable_buffers_1(part.data(), part.size()),
callback);
}
return parsed_ok;
Expand Down Expand Up @@ -186,7 +187,7 @@ struct http_async_protocol_handler {
std::end(result_range));
part_begin = part.begin();
delegate_->read_some(
boost::asio::mutable_buffers_1(part.c_array(), part.size()),
boost::asio::mutable_buffers_1(part.data(), part.size()),
callback);
}
return parsed_ok;
Expand Down Expand Up @@ -231,7 +232,7 @@ struct http_async_protocol_handler {
std::end(result_range));
part_begin = part.begin();
delegate_->read_some(
boost::asio::mutable_buffers_1(part.c_array(), part.size()),
boost::asio::mutable_buffers_1(part.data(), part.size()),
callback);
}
return parsed_ok;
Expand Down Expand Up @@ -318,7 +319,7 @@ struct http_async_protocol_handler {
std::end(result_range));
part_begin = part.begin();
delegate_->read_some(
boost::asio::mutable_buffers_1(part.c_array(), part.size()),
boost::asio::mutable_buffers_1(part.data(), part.size()),
callback);
}
return fusion::make_tuple(
Expand All @@ -332,12 +333,12 @@ struct http_async_protocol_handler {
partial_parsed.append(part_begin, bytes);
part_begin = part.begin();
delegate_->read_some(
boost::asio::mutable_buffers_1(part.c_array(), part.size()), callback);
boost::asio::mutable_buffers_1(part.data(), part.size()), callback);
}

typedef response_parser<Tag> response_parser_type;
// TODO(dberris): make 1024 go away and become a configurable value.
typedef boost::array<typename char_<Tag>::type, 1024> buffer_type;
typedef std::array<typename char_<Tag>::type, 1024> buffer_type;

response_parser_type response_parser_;
std::promise<string_type> version_promise;
Expand Down
5 changes: 3 additions & 2 deletions boost/network/protocol/http/server/async_connection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <vector>
#include <memory>
#include <mutex>
#include <array>
#include <boost/asio/buffer.hpp>
#include <boost/asio/ip/tcp.hpp>
#include <boost/asio/strand.hpp>
Expand Down Expand Up @@ -287,7 +288,7 @@ struct async_connection
}

private:
typedef boost::array<char, BOOST_NETWORK_HTTP_SERVER_CONNECTION_BUFFER_SIZE>
typedef std::array<char, BOOST_NETWORK_HTTP_SERVER_CONNECTION_BUFFER_SIZE>
buffer_type;

public:
Expand Down Expand Up @@ -344,7 +345,7 @@ struct async_connection
if (ec) error_encountered = in_place<boost::system::system_error>(ec);
}

typedef boost::array<char, BOOST_NETWORK_HTTP_SERVER_CONNECTION_BUFFER_SIZE>
typedef std::array<char, BOOST_NETWORK_HTTP_SERVER_CONNECTION_BUFFER_SIZE>
array;
typedef std::list<std::shared_ptr<array> > array_list;
typedef std::shared_ptr<array_list> shared_array_list;
Expand Down
4 changes: 2 additions & 2 deletions boost/network/protocol/http/server/sync_connection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#endif

#include <memory>
#include <array>
#include <boost/network/protocol/http/request_parser.hpp>
#include <boost/network/protocol/http/request.hpp>
#include <boost/network/protocol/http/response.hpp>
Expand All @@ -23,7 +24,6 @@
#include <boost/asio/read.hpp>
#include <boost/asio/strand.hpp>
#include <boost/asio/placeholders.hpp>
#include <boost/array.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string/case_conv.hpp>
#include <boost/bind.hpp>
Expand Down Expand Up @@ -215,7 +215,7 @@ struct sync_connection
boost::asio::ip::tcp::socket socket_;
boost::asio::io_service::strand wrapper_;

typedef boost::array<char, BOOST_NETWORK_HTTP_SERVER_CONNECTION_BUFFER_SIZE>
typedef std::array<char, BOOST_NETWORK_HTTP_SERVER_CONNECTION_BUFFER_SIZE>
buffer_type;
buffer_type buffer_;
typedef basic_request_parser<Tag> request_parser;
Expand Down
4 changes: 2 additions & 2 deletions libs/network/test/utils_base64_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
#include <boost/test/unit_test.hpp>
#include <boost/network/utils/base64/encode.hpp>
#include <boost/network/utils/base64/encode-io.hpp>
#include <boost/array.hpp>
#include <algorithm>
#include <iterator>
#include <string>
#include <vector>
#include <sstream>
#include <array>

using namespace boost::network::utils;

Expand Down Expand Up @@ -55,7 +55,7 @@ BOOST_AUTO_TEST_CASE(interface_test) {
BOOST_CHECK_EQUAL(base64::encode<char>(char_array), "YWJj");

// check boost::array of chars
boost::array<char, 3> char_boost_array = {{'a', 'b', 'c'}};
std::array<char, 3> char_boost_array = {{'a', 'b', 'c'}};

BOOST_CHECK_EQUAL(base64::encode<char>(char_boost_array), "YWJj");

Expand Down