Skip to content

Commit

Permalink
Fix message constructor and special members
Browse files Browse the repository at this point in the history
  • Loading branch information
vinniefalco committed Nov 20, 2016
1 parent 2d3d3a6 commit be1bce8
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
1.0.0-b21

* Add WebSocket permessage-deflate extension support
* Fix message constructor and special members

--------------------------------------------------------------------------------

Expand Down
19 changes: 16 additions & 3 deletions include/beast/http/message.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,18 @@ struct message : header<isRequest, Fields>
/// Default constructor
message() = default;

/// Move constructor
message(message&&) = default;

/// Copy constructor
message(message const&) = default;

/// Move assignment
message& operator=(message&&) = default;

/// Copy assignment
message& operator=(message const&) = default;

/** Construct a message from a header.
Additional arguments, if any, are forwarded to
Expand Down Expand Up @@ -281,8 +293,9 @@ struct message : header<isRequest, Fields>
*/
template<class U
#if ! GENERATING_DOCS
, class = typename std::enable_if<! std::is_convertible<
typename std::decay<U>::type, base_type>::value>
, class = typename std::enable_if<
! std::is_convertible<typename
std::decay<U>::type, base_type>::value>::type
#endif
>
explicit
Expand All @@ -303,7 +316,7 @@ struct message : header<isRequest, Fields>
template<class U, class V
#if ! GENERATING_DOCS
,class = typename std::enable_if<! std::is_convertible<
typename std::decay<U>::type, base_type>::value>
typename std::decay<U>::type, base_type>::value>::type
#endif
>
message(U&& u, V&& v)
Expand Down
14 changes: 14 additions & 0 deletions test/http/message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,13 +278,27 @@ class message_test : public beast::unit_test::suite
BEAST_EXPECT(m2.fields.exists("h"));
}

void
testSpecialMembers()
{
response<string_body> r1;
response<string_body> r2{r1};
response<string_body> r3{std::move(r2)};
r2 = r3;
r1 = std::move(r2);
[r1]()
{
}();
}

void run() override
{
testMessage();
testHeaders();
testFreeFunctions();
testPrepare();
testSwap();
testSpecialMembers();
}
};

Expand Down

0 comments on commit be1bce8

Please sign in to comment.