diff --git a/CHANGELOG.md b/CHANGELOG.md index 7cab5e43..c3dc721a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +Version 206 + +* Clear error codes idiomatically + +-------------------------------------------------------------------------------- + Version 205 * Doc work diff --git a/example/common/detect_ssl.hpp b/example/common/detect_ssl.hpp index 417226e4..9e6c394c 100644 --- a/example/common/detect_ssl.hpp +++ b/example/common/detect_ssl.hpp @@ -154,7 +154,7 @@ detect_ssl( { // This is a fast way to indicate success // without retrieving the default category. - ec.assign(0, ec.category()); + ec = {}; return result; } diff --git a/example/doc/http_examples.hpp b/example/doc/http_examples.hpp index b946d68c..409893d2 100644 --- a/example/doc/http_examples.hpp +++ b/example/doc/http_examples.hpp @@ -1094,7 +1094,7 @@ read_and_print_body( p.get().body().size = sizeof(buf); read(stream, buffer, p, ec); if(ec == error::need_buffer) - ec.assign(0, ec.category()); + ec = {}; if(ec) return; os.write(buf, sizeof(buf) - p.get().body().size); @@ -1201,7 +1201,7 @@ print_chunked_body( else if(ec != error::end_of_chunk) return; else - ec.assign(0, ec.category()); + ec = {}; // We got a whole chunk, print the extensions: for(auto const& extension : ce) diff --git a/example/http/client/async-ssl/http_client_async_ssl.cpp b/example/http/client/async-ssl/http_client_async_ssl.cpp index 889a4da0..2093a876 100644 --- a/example/http/client/async-ssl/http_client_async_ssl.cpp +++ b/example/http/client/async-ssl/http_client_async_ssl.cpp @@ -191,7 +191,7 @@ public: { // Rationale: // http://stackoverflow.com/questions/25587403/boost-asio-ssl-async-shutdown-always-finishes-with-an-error - ec.assign(0, ec.category()); + ec = {}; } if(ec) return fail(ec, "shutdown"); diff --git a/example/http/client/coro-ssl/http_client_coro_ssl.cpp b/example/http/client/coro-ssl/http_client_coro_ssl.cpp index 47e876ac..cd4fc8af 100644 --- a/example/http/client/coro-ssl/http_client_coro_ssl.cpp +++ b/example/http/client/coro-ssl/http_client_coro_ssl.cpp @@ -113,7 +113,7 @@ do_session( { // Rationale: // http://stackoverflow.com/questions/25587403/boost-asio-ssl-async-shutdown-always-finishes-with-an-error - ec.assign(0, ec.category()); + ec = {}; } if(ec) return fail(ec, "shutdown"); diff --git a/example/http/client/sync-ssl/http_client_sync_ssl.cpp b/example/http/client/sync-ssl/http_client_sync_ssl.cpp index f0ed8cef..b2751c63 100644 --- a/example/http/client/sync-ssl/http_client_sync_ssl.cpp +++ b/example/http/client/sync-ssl/http_client_sync_ssl.cpp @@ -111,7 +111,7 @@ int main(int argc, char** argv) { // Rationale: // http://stackoverflow.com/questions/25587403/boost-asio-ssl-async-shutdown-always-finishes-with-an-error - ec.assign(0, ec.category()); + ec = {}; } if(ec) throw beast::system_error{ec}; diff --git a/include/boost/beast/http/basic_dynamic_body.hpp b/include/boost/beast/http/basic_dynamic_body.hpp index 156c2205..5d012ec0 100644 --- a/include/boost/beast/http/basic_dynamic_body.hpp +++ b/include/boost/beast/http/basic_dynamic_body.hpp @@ -80,7 +80,7 @@ struct basic_dynamic_body init(boost::optional< std::uint64_t> const&, error_code& ec) { - ec.assign(0, ec.category()); + ec = {}; } template @@ -112,7 +112,7 @@ struct basic_dynamic_body void finish(error_code& ec) { - ec.assign(0, ec.category()); + ec = {}; } }; #endif @@ -142,13 +142,13 @@ struct basic_dynamic_body void init(error_code& ec) { - ec.assign(0, ec.category()); + ec = {}; } boost::optional> get(error_code& ec) { - ec.assign(0, ec.category()); + ec = {}; return {{body_.data(), false}}; } }; diff --git a/include/boost/beast/http/basic_file_body.hpp b/include/boost/beast/http/basic_file_body.hpp index 67a169e1..65b92568 100644 --- a/include/boost/beast/http/basic_file_body.hpp +++ b/include/boost/beast/http/basic_file_body.hpp @@ -319,7 +319,7 @@ init(error_code& ec) // to indicate no error. // // We don't do anything fancy so set "no error" - ec.assign(0, ec.category()); + ec = {}; } // This function is called repeatedly by the serializer to @@ -349,7 +349,7 @@ get(error_code& ec) -> // into the library to get the generic category because // that saves us a possibly expensive atomic operation. // - ec.assign(0, ec.category()); + ec = {}; return boost::none; } @@ -373,7 +373,7 @@ get(error_code& ec) -> // we set this bool to `false` so we will not be called // again. // - ec.assign(0, ec.category()); + ec = {}; return {{ const_buffers_type{buf_, nread}, // buffer to return. remain_ > 0 // `true` if there are more buffers. @@ -474,7 +474,7 @@ init( // to indicate no error. // // We don't do anything fancy so set "no error" - ec.assign(0, ec.category()); + ec = {}; } // This will get called one or more times with body buffers @@ -505,7 +505,7 @@ put(ConstBufferSequence const& buffers, error_code& ec) // Indicate success // This is required by the error_code specification - ec.assign(0, ec.category()); + ec = {}; return nwritten; } @@ -519,7 +519,7 @@ finish(error_code& ec) { // This has to be cleared before returning, to // indicate no error. The specification requires it. - ec.assign(0, ec.category()); + ec = {}; } //] diff --git a/include/boost/beast/http/buffer_body.hpp b/include/boost/beast/http/buffer_body.hpp index 8d9448c1..b69f537f 100644 --- a/include/boost/beast/http/buffer_body.hpp +++ b/include/boost/beast/http/buffer_body.hpp @@ -113,7 +113,7 @@ struct buffer_body void init(boost::optional const&, error_code& ec) { - ec.assign(0, ec.category()); + ec = {}; } template @@ -135,7 +135,7 @@ struct buffer_body body_.data) + bytes_transferred; body_.size -= bytes_transferred; if(bytes_transferred == buffer_size(buffers)) - ec.assign(0, ec.category()); + ec = {}; else ec = error::need_buffer; return bytes_transferred; @@ -144,7 +144,7 @@ struct buffer_body void finish(error_code& ec) { - ec.assign(0, ec.category()); + ec = {}; } }; #endif @@ -175,7 +175,7 @@ struct buffer_body void init(error_code& ec) { - ec.assign(0, ec.category()); + ec = {}; } boost::optional< @@ -191,13 +191,13 @@ struct buffer_body } else { - ec.assign(0, ec.category()); + ec = {}; } return boost::none; } if(body_.data) { - ec.assign(0, ec.category()); + ec = {}; toggle_ = true; return {{const_buffers_type{ body_.data, body_.size}, body_.more}}; @@ -205,7 +205,7 @@ struct buffer_body if(body_.more) ec = error::need_buffer; else - ec.assign(0, ec.category()); + ec = {}; return boost::none; } }; diff --git a/include/boost/beast/http/detail/basic_parser.hpp b/include/boost/beast/http/detail/basic_parser.hpp index 741de6ed..87ce1f33 100644 --- a/include/boost/beast/http/detail/basic_parser.hpp +++ b/include/boost/beast/http/detail/basic_parser.hpp @@ -191,14 +191,14 @@ struct basic_parser_base { if(it == last) { - ec.assign(0, ec.category()); + ec = {}; return nullptr; } if(*it == '\r') { if(++it == last) { - ec.assign(0, ec.category()); + ec = {}; return nullptr; } if(*it != '\n') @@ -206,7 +206,7 @@ struct basic_parser_base ec = error::bad_line_ending; return nullptr; } - ec.assign(0, ec.category()); + ec = {}; return ++it; } // VFALCO Should we handle the legacy case diff --git a/include/boost/beast/http/empty_body.hpp b/include/boost/beast/http/empty_body.hpp index ec43e92c..c70e6ade 100644 --- a/include/boost/beast/http/empty_body.hpp +++ b/include/boost/beast/http/empty_body.hpp @@ -70,7 +70,7 @@ struct empty_body void init(boost::optional const&, error_code& ec) { - ec.assign(0, ec.category()); + ec = {}; } template @@ -85,7 +85,7 @@ struct empty_body void finish(error_code& ec) { - ec.assign(0, ec.category()); + ec = {}; } }; #endif @@ -111,13 +111,13 @@ struct empty_body void init(error_code& ec) { - ec.assign(0, ec.category()); + ec = {}; } boost::optional> get(error_code& ec) { - ec.assign(0, ec.category()); + ec = {}; return boost::none; } }; diff --git a/include/boost/beast/http/impl/basic_parser.ipp b/include/boost/beast/http/impl/basic_parser.ipp index 93bf3d40..f290dd7b 100644 --- a/include/boost/beast/http/impl/basic_parser.ipp +++ b/include/boost/beast/http/impl/basic_parser.ipp @@ -100,7 +100,7 @@ put(ConstBufferSequence const& buffers, auto const last = net::buffer_sequence_end(buffers); if(p == last) { - ec.assign(0, ec.category()); + ec = {}; return 0; } if(std::next(p) == last) @@ -136,7 +136,7 @@ put(net::const_buffer const& buffer, auto n = buffer.size(); auto const p0 = p; auto const p1 = p0 + n; - ec.assign(0, ec.category()); + ec = {}; loop: switch(state_) { @@ -255,7 +255,7 @@ loop: break; case state::complete: - ec.assign(0, ec.category()); + ec = {}; goto done; } if(p < p1 && ! is_done() && eager()) @@ -286,7 +286,7 @@ put_eof(error_code& ec) ec = error::partial_message; return; } - ec.assign(0, ec.category()); + ec = {}; return; } impl().on_finish_impl(ec); @@ -841,7 +841,7 @@ do_field(field f, continue; } } - ec.assign(0, ec.category()); + ec = {}; return; } @@ -870,7 +870,7 @@ do_field(field f, return; } - ec.assign(0, ec.category()); + ec = {}; len_ = v; f_ |= flagContentLength; return; @@ -893,7 +893,7 @@ do_field(field f, return; } - ec.assign(0, ec.category()); + ec = {}; auto const v = token_list{value}; auto const p = std::find_if(v.begin(), v.end(), [&](typename token_list::value_type const& s) @@ -912,12 +912,12 @@ do_field(field f, // Upgrade if(f == field::upgrade) { - ec.assign(0, ec.category()); + ec = {}; f_ |= flagUpgrade; return; } - ec.assign(0, ec.category()); + ec = {}; } } // http diff --git a/include/boost/beast/http/impl/chunk_encode.ipp b/include/boost/beast/http/impl/chunk_encode.ipp index b8cf86d7..0c808d07 100644 --- a/include/boost/beast/http/impl/chunk_encode.ipp +++ b/include/boost/beast/http/impl/chunk_encode.ipp @@ -387,7 +387,7 @@ do_parse(FwdIt it, FwdIt last, error_code& ec) loop: if(it == last) { - ec.assign(0, ec.category()); + ec = {}; return it; } // BWS diff --git a/include/boost/beast/http/impl/file_body_win32.ipp b/include/boost/beast/http/impl/file_body_win32.ipp index 15dfd2cf..5c59ad26 100644 --- a/include/boost/beast/http/impl/file_body_win32.ipp +++ b/include/boost/beast/http/impl/file_body_win32.ipp @@ -142,7 +142,7 @@ struct basic_file_body beast::detail::clamp(body_.last_ - pos_)); if(n == 0) { - ec.assign(0, ec.category()); + ec = {}; return boost::none; } auto const nread = body_.file_.read(buf_, n, ec); @@ -150,7 +150,7 @@ struct basic_file_body return boost::none; BOOST_ASSERT(nread != 0); pos_ += nread; - ec.assign(0, ec.category()); + ec = {}; return {{ {buf_, nread}, // buffer to return. pos_ < body_.last_}}; // `true` if there are more buffers. @@ -179,7 +179,7 @@ struct basic_file_body // VFALCO We could reserve space in the file boost::ignore_unused(content_length); BOOST_ASSERT(body_.file_.is_open()); - ec.assign(0, ec.category()); + ec = {}; } template @@ -195,14 +195,14 @@ struct basic_file_body if(ec) return nwritten; } - ec.assign(0, ec.category()); + ec = {}; return nwritten; } void finish(error_code& ec) { - ec.assign(0, ec.category()); + ec = {}; } }; @@ -496,7 +496,7 @@ write_some( BOOST_ASSERT(w.pos_ <= w.body_.last_); if(w.pos_ < w.body_.last_) { - ec.assign(0, ec.category()); + ec = {}; } else { diff --git a/include/boost/beast/http/impl/write.ipp b/include/boost/beast/http/impl/write.ipp index 4833d3fc..7ab73e9d 100644 --- a/include/boost/beast/http/impl/write.ipp +++ b/include/boost/beast/http/impl/write.ipp @@ -327,7 +327,7 @@ write_some_impl( sr.consume(f.bytes_transferred); return f.bytes_transferred; } - ec.assign(0, ec.category()); + ec = {}; return 0; } @@ -475,7 +475,7 @@ write_header( } else { - ec.assign(0, ec.category()); + ec = {}; } return bytes_transferred; } @@ -764,7 +764,7 @@ public: operator()(error_code& ec, ConstBufferSequence const& buffers) const { - ec.assign(0, ec.category()); + ec = {}; if(os_.fail()) return; std::size_t bytes_transferred = 0; diff --git a/include/boost/beast/http/parser.hpp b/include/boost/beast/http/parser.hpp index 3e166a9d..496b404a 100644 --- a/include/boost/beast/http/parser.hpp +++ b/include/boost/beast/http/parser.hpp @@ -347,7 +347,7 @@ private: m_.method(method); else m_.method_string(method_str); - ec.assign(0, ec.category()); + ec = {}; } catch(std::bad_alloc const&) { @@ -368,7 +368,7 @@ private: try { m_.reason(reason); - ec.assign(0, ec.category()); + ec = {}; } catch(std::bad_alloc const&) { @@ -386,7 +386,7 @@ private: try { m_.insert(name, name_string, value); - ec.assign(0, ec.category()); + ec = {}; } catch(std::bad_alloc const&) { @@ -397,7 +397,7 @@ private: void on_header_impl(error_code& ec) { - ec.assign(0, ec.category()); + ec = {}; } void @@ -426,7 +426,7 @@ private: { if(cb_h_) return cb_h_(size, extensions, ec); - ec.assign(0, ec.category()); + ec = {}; } std::size_t diff --git a/include/boost/beast/http/span_body.hpp b/include/boost/beast/http/span_body.hpp index 6bfb3729..8afa51ea 100644 --- a/include/boost/beast/http/span_body.hpp +++ b/include/boost/beast/http/span_body.hpp @@ -87,7 +87,7 @@ public: ec = error::buffer_overflow; return; } - ec.assign(0, ec.category()); + ec = {}; } template @@ -104,7 +104,7 @@ public: ec = error::buffer_overflow; return 0; } - ec.assign(0, ec.category()); + ec = {}; buffer_copy(net::buffer( body_.data(), n), buffers); body_ = value_type{ @@ -115,7 +115,7 @@ public: void finish(error_code& ec) { - ec.assign(0, ec.category()); + ec = {}; } }; #endif @@ -145,13 +145,13 @@ public: void init(error_code& ec) { - ec.assign(0, ec.category()); + ec = {}; } boost::optional> get(error_code& ec) { - ec.assign(0, ec.category()); + ec = {}; return {{ { body_.data(), body_.size() * sizeof(typename diff --git a/include/boost/beast/http/string_body.hpp b/include/boost/beast/http/string_body.hpp index 95b69622..8c1541ce 100644 --- a/include/boost/beast/http/string_body.hpp +++ b/include/boost/beast/http/string_body.hpp @@ -109,7 +109,7 @@ public: return; } } - ec.assign(0, ec.category()); + ec = {}; } template @@ -130,7 +130,7 @@ public: ec = error::buffer_overflow; return 0; } - ec.assign(0, ec.category()); + ec = {}; CharT* dest = &body_[size]; for(auto b : beast::buffers_range_ref(buffers)) { @@ -144,7 +144,7 @@ public: void finish(error_code& ec) { - ec.assign(0, ec.category()); + ec = {}; } }; #endif @@ -174,13 +174,13 @@ public: void init(error_code& ec) { - ec.assign(0, ec.category()); + ec = {}; } boost::optional> get(error_code& ec) { - ec.assign(0, ec.category()); + ec = {}; return {{const_buffers_type{ body_.data(), body_.size()}, false}}; } diff --git a/include/boost/beast/http/vector_body.hpp b/include/boost/beast/http/vector_body.hpp index fdc8b9a6..a7d74ef0 100644 --- a/include/boost/beast/http/vector_body.hpp +++ b/include/boost/beast/http/vector_body.hpp @@ -103,7 +103,7 @@ public: return; } } - ec.assign(0, ec.category()); + ec = {}; } template @@ -124,7 +124,7 @@ public: ec = error::buffer_overflow; return 0; } - ec.assign(0, ec.category()); + ec = {}; return buffer_copy(net::buffer( &body_[0] + len, n), buffers); } @@ -132,7 +132,7 @@ public: void finish(error_code& ec) { - ec.assign(0, ec.category()); + ec = {}; } }; #endif @@ -162,13 +162,13 @@ public: void init(error_code& ec) { - ec.assign(0, ec.category()); + ec = {}; } boost::optional> get(error_code& ec) { - ec.assign(0, ec.category()); + ec = {}; return {{const_buffers_type{ body_.data(), body_.size()}, false}}; } diff --git a/include/boost/beast/websocket/detail/frame.hpp b/include/boost/beast/websocket/detail/frame.hpp index 9c68774f..7dde553b 100644 --- a/include/boost/beast/websocket/detail/frame.hpp +++ b/include/boost/beast/websocket/detail/frame.hpp @@ -259,7 +259,7 @@ read_close( if(n == 0) { cr = close_reason{}; - ec.assign(0, ec.category()); + ec = {}; return; } if(n == 1) @@ -298,7 +298,7 @@ read_close( { cr.reason = ""; } - ec.assign(0, ec.category()); + ec = {}; } } // detail diff --git a/include/boost/beast/websocket/stream.hpp b/include/boost/beast/websocket/stream.hpp index 03e9ecd1..35a46573 100644 --- a/include/boost/beast/websocket/stream.hpp +++ b/include/boost/beast/websocket/stream.hpp @@ -3388,7 +3388,7 @@ private: ec = net::error::operation_aborted; return false; } - ec.assign(0, ec.category()); + ec = {}; return true; } diff --git a/include/boost/beast/zlib/detail/deflate_stream.hpp b/include/boost/beast/zlib/detail/deflate_stream.hpp index f0a91e8a..c9412005 100644 --- a/include/boost/beast/zlib/detail/deflate_stream.hpp +++ b/include/boost/beast/zlib/detail/deflate_stream.hpp @@ -1006,7 +1006,7 @@ doParams(z_params& zs, int level, Strategy strategy, error_code& ec) // Flush the last buffer: doWrite(zs, Flush::block, ec); if(ec == error::need_buffers && pending_ == 0) - ec.assign(0, ec.category()); + ec = {}; } if(level_ != level) { diff --git a/test/beast/http/parser.cpp b/test/beast/http/parser.cpp index fc3aefe1..43c7a669 100644 --- a/test/beast/http/parser.cpp +++ b/test/beast/http/parser.cpp @@ -97,7 +97,7 @@ public: p.put(buffer(s.data(), n), ec); s.remove_prefix(used); if(ec == error::need_more) - ec.assign(0, ec.category()); + ec = {}; if(! BEAST_EXPECTS(! ec, ec.message())) continue; BEAST_EXPECT(! p.is_done()); @@ -258,7 +258,7 @@ public: used = p.put(b.data(), ec); b.consume(used); BEAST_EXPECT(ec == error::need_more); - ec.assign(0, ec.category()); + ec = {}; BEAST_EXPECT(! p.is_done()); ostream(b) << "\r\n"; // final crlf to end message @@ -302,7 +302,7 @@ public: used = p.put(b.data(), ec); BEAST_EXPECTS(ec == error::need_more, ec.message()); b.consume(used); - ec.assign(0, ec.category()); + ec = {}; ostream(b) << "User-Agent: test\r\n" "\r\n"; @@ -323,7 +323,7 @@ public: BEAST_EXPECT(ec == error::need_more); BEAST_EXPECT(! p.got_some()); BEAST_EXPECT(used == 0); - ec.assign(0, ec.category()); + ec = {}; used = p.put(buf("G"), ec); BEAST_EXPECT(ec == error::need_more); BEAST_EXPECT(p.got_some()); diff --git a/test/beast/http/test_parser.hpp b/test/beast/http/test_parser.hpp index def84b21..b99716d2 100644 --- a/test/beast/http/test_parser.hpp +++ b/test/beast/http/test_parser.hpp @@ -66,7 +66,7 @@ public: if(fc_) fc_->fail(ec); else - ec.assign(0, ec.category()); + ec = {}; } void @@ -82,7 +82,7 @@ public: if(fc_) fc_->fail(ec); else - ec.assign(0, ec.category()); + ec = {}; } void @@ -93,7 +93,7 @@ public: if(fc_) fc_->fail(ec); else - ec.assign(0, ec.category()); + ec = {}; fields[name.to_string()] = value.to_string(); } @@ -104,7 +104,7 @@ public: if(fc_) fc_->fail(ec); else - ec.assign(0, ec.category()); + ec = {}; } void @@ -118,7 +118,7 @@ public: if(fc_) fc_->fail(ec); else - ec.assign(0, ec.category()); + ec = {}; } std::size_t @@ -129,7 +129,7 @@ public: if(fc_) fc_->fail(ec); else - ec.assign(0, ec.category()); + ec = {}; return s.size(); } @@ -143,7 +143,7 @@ public: if(fc_) fc_->fail(ec); else - ec.assign(0, ec.category()); + ec = {}; } std::size_t @@ -156,7 +156,7 @@ public: if(fc_) fc_->fail(ec); else - ec.assign(0, ec.category()); + ec = {}; return s.size(); } @@ -168,7 +168,7 @@ public: if(fc_) fc_->fail(ec); else - ec.assign(0, ec.category()); + ec = {}; } }; diff --git a/test/beast/http/write.cpp b/test/beast/http/write.cpp index cbfe931b..83471356 100644 --- a/test/beast/http/write.cpp +++ b/test/beast/http/write.cpp @@ -60,13 +60,13 @@ public: void init(error_code& ec) { - ec.assign(0, ec.category()); + ec = {}; } boost::optional> get(error_code& ec) { - ec.assign(0, ec.category()); + ec = {}; return {{const_buffers_type{ body_.data(), body_.size()}, false}}; } @@ -105,13 +105,13 @@ public: void init(error_code& ec) { - ec.assign(0, ec.category()); + ec = {}; } boost::optional> get(error_code& ec) { - ec.assign(0, ec.category()); + ec = {}; body_.read = true; return get( std::integral_constant{}, @@ -916,13 +916,13 @@ public: void init(error_code& ec) { - ec.assign(0, ec.category()); + ec = {}; } boost::optional> get(error_code& ec) { - ec.assign(0, ec.category()); + ec = {}; return {{const_buffers_type{"", 0}, false}}; } }; @@ -947,13 +947,13 @@ public: void init(error_code& ec) { - ec.assign(0, ec.category()); + ec = {}; } boost::optional> get(error_code& ec) { - ec.assign(0, ec.category()); + ec = {}; return {{const_buffers_type{"", 0}, false}}; } }; diff --git a/test/bench/parser/bench_parser.cpp b/test/bench/parser/bench_parser.cpp index 6a13b6d2..ea936152 100644 --- a/test/bench/parser/bench_parser.cpp +++ b/test/bench/parser/bench_parser.cpp @@ -164,7 +164,7 @@ public: on_request_impl(verb, string_view, string_view, int, error_code& ec) { - ec.assign(0, ec.category()); + ec = {}; } void @@ -172,20 +172,20 @@ public: string_view, int, error_code& ec) { - ec.assign(0, ec.category()); + ec = {}; } void on_field_impl(field, string_view, string_view, error_code& ec) { - ec.assign(0, ec.category()); + ec = {}; } void on_header_impl(error_code& ec) { - ec.assign(0, ec.category()); + ec = {}; } void @@ -193,13 +193,13 @@ public: boost::optional const&, error_code& ec) { - ec.assign(0, ec.category()); + ec = {}; } std::size_t on_body_impl(string_view s, error_code& ec) { - ec.assign(0, ec.category()); + ec = {}; return s.size(); } @@ -207,21 +207,21 @@ public: on_chunk_header_impl(std::uint64_t, string_view, error_code& ec) { - ec.assign(0, ec.category()); + ec = {}; } std::size_t on_chunk_body_impl(std::uint64_t, string_view s, error_code& ec) { - ec.assign(0, ec.category()); + ec = {}; return s.size(); } void on_finish_impl(error_code& ec) { - ec.assign(0, ec.category()); + ec = {}; } }; diff --git a/test/bench/parser/nodejs_parser.hpp b/test/bench/parser/nodejs_parser.hpp index 951a926b..d94a2933 100644 --- a/test/bench/parser/nodejs_parser.hpp +++ b/test/bench/parser/nodejs_parser.hpp @@ -572,7 +572,7 @@ private: // Transfer-Encoding, see if we can reserve the buffer. // // r_.reserve(content_length) - ec.assign(0, ec.category()); + ec = {}; } bool @@ -625,7 +625,7 @@ private: void on_body(void const*, std::size_t, error_code& ec) { - ec.assign(0, ec.category()); + ec = {}; } void diff --git a/test/doc/exemplars.cpp b/test/doc/exemplars.cpp index 0f5dc743..34bf3814 100644 --- a/test/doc/exemplars.cpp +++ b/test/doc/exemplars.cpp @@ -76,7 +76,7 @@ public: init(error_code& ec) { // The specification requires this to indicate "no error" - ec.assign(0, ec.category()); + ec = {}; } /** Returns the next buffer in the body. @@ -101,7 +101,7 @@ public: get(error_code& ec) { // The specification requires this to indicate "no error" - ec.assign(0, ec.category()); + ec = {}; return boost::none; // for exposition only } @@ -144,7 +144,7 @@ struct BodyReader boost::ignore_unused(content_length); // The specification requires this to indicate "no error" - ec.assign(0, ec.category()); + ec = {}; } /** Store buffers. diff --git a/test/doc/http_snippets.cpp b/test/doc/http_snippets.cpp index 1547de72..a950f585 100644 --- a/test/doc/http_snippets.cpp +++ b/test/doc/http_snippets.cpp @@ -365,7 +365,7 @@ print_cxx14(message const& m) sr.next(ec, [&sr](error_code& ec, auto const& buffer) { - ec.assign(0, ec.category()); + ec = {}; std::cout << buffers(buffer); sr.consume(net::buffer_size(buffer)); }); @@ -392,7 +392,7 @@ struct lambda template void operator()(error_code& ec, ConstBufferSequence const& buffer) const { - ec.assign(0, ec.category()); + ec = {}; std::cout << buffers(buffer); sr.consume(net::buffer_size(buffer)); } @@ -433,7 +433,7 @@ split_print_cxx14(message const& m) sr.next(ec, [&sr](error_code& ec, auto const& buffer) { - ec.assign(0, ec.category()); + ec = {}; std::cout << buffers(buffer); sr.consume(net::buffer_size(buffer)); }); @@ -447,7 +447,7 @@ split_print_cxx14(message const& m) sr.next(ec, [&sr](error_code& ec, auto const& buffer) { - ec.assign(0, ec.category()); + ec = {}; std::cout << buffers(buffer); sr.consume(net::buffer_size(buffer)); });