Add ref-qualified overloads for message::body

This commit is contained in:
Vinnie Falco
2017-10-30 14:45:16 -07:00
parent e39e4c73bf
commit 23bf8638ab
5 changed files with 55 additions and 3 deletions

View File

@ -2,6 +2,7 @@ Version 132:
* Tidy up project folders in CMakeLists.txt
* Rename Cmake variables for clarity
* Add ref-qualified overloads for message::body
--------------------------------------------------------------------------------

Binary file not shown.

Before

Width:  |  Height:  |  Size: 43 KiB

After

Width:  |  Height:  |  Size: 50 KiB

View File

@ -106,7 +106,7 @@ member functions of `Fields`. This diagram shows the inheritance
relationship between header and message, along with some of the
notable differences in members in each partial specialization:
[$beast/images/message.png [width 730px] [height 410px]]
[$beast/images/message.png [width 730px] [height 459px]]
[heading:body Body Types]

View File

@ -849,7 +849,7 @@ struct message
#else
detail::value_type_t<Body>&
#endif
body() noexcept
body()& noexcept
{
return this->member();
}
@ -860,11 +860,33 @@ struct message
#else
detail::value_type_t<Body> const&
#endif
body() const noexcept
body() const& noexcept
{
return this->member();
}
/// Returns the body
#if BOOST_BEAST_DOXYGEN || ! defined(BOOST_MSVC)
typename body_type::value_type&&
#else
detail::value_type_t<Body>&&
#endif
body()&& noexcept
{
return std::move(this->member());
}
/// Returns the body
#if BOOST_BEAST_DOXYGEN || ! defined(BOOST_MSVC)
typename body_type::value_type const&&
#else
detail::value_type_t<Body> const&&
#endif
body() const&& noexcept
{
return std::move(this->member());
}
private:
static_assert(is_body<Body>::value,
"Body requirements not met");

View File

@ -273,6 +273,34 @@ public:
}
}
void
testBody()
{
{
auto f = [](empty_body::value_type&){};
request<empty_body> m;
f(m.body());
}
{
auto f = [](empty_body::value_type const&){};
request<empty_body> const m;
f(m.body());
f(std::move(m.body()));
}
{
auto f = [](empty_body::value_type&&){};
request<empty_body> m;
f(std::move(m).body());
f(std::move(m.body()));
}
{
auto f = [](empty_body::value_type const&&){};
request<empty_body> const m;
f(std::move(m).body());
f(std::move(m.body()));
}
}
void
testSwap()
{
@ -477,6 +505,7 @@ public:
{
testMessage();
testMessageCtors();
testBody();
testSwap();
testSpecialMembers();
testMethod();