Use SFINAE on return values

This commit is contained in:
Vinnie Falco
2016-05-27 11:10:45 -04:00
parent 472d90eb3b
commit 8686b28cf2
4 changed files with 19 additions and 21 deletions

View File

@@ -1,3 +1,6 @@
1.0.0-b6 1.0.0-b6
* Use SFINAE on return values
* Use beast::error_code instead of nested types
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------

View File

@@ -1,9 +1,5 @@
* Add writer::prepare(msg&) interface to set Content-Type * Add writer::prepare(msg&) interface to set Content-Type
General:
* Use SFINAE on return values (search for "class =")
* Remove http,websocket error_code types and use the one in <beast/error.hpp>
Boost.Http Boost.Http
* Use enum instead of bool in isRequest * Use enum instead of bool in isRequest
* move version to a subclass of message * move version to a subclass of message

View File

@@ -25,15 +25,16 @@ namespace beast {
@return A string representing the contents of the input area. @return A string representing the contents of the input area.
@note This function participates in overload resolution only if @note This function participates in overload resolution only if
the streambuf parameter meets the requirements of @b `Streambuf`. the buffers parameter meets the requirements of @b `ConstBufferSequence`.
*/ */
template<class ConstBufferSequence template<class ConstBufferSequence>
#if ! GENERATING_DOCS #if GENERATING_DOCS
,class = std::enable_if<is_ConstBufferSequence<
ConstBufferSequence>::value>
#endif
>
std::string std::string
#else
typename std::enable_if<
is_ConstBufferSequence<ConstBufferSequence>::value,
std::string>::type
#endif
to_string(ConstBufferSequence const& buffers) to_string(ConstBufferSequence const& buffers)
{ {
using boost::asio::buffer_cast; using boost::asio::buffer_cast;

View File

@@ -401,10 +401,9 @@ public:
If a field value already exists the new value will be If a field value already exists the new value will be
extended as per RFC2616 Section 4.2. extended as per RFC2616 Section 4.2.
*/ */
template<class T, template<class T>
class = typename std::enable_if< typename std::enable_if<
! std::is_constructible<boost::string_ref, T>::value>::type> ! std::is_constructible<boost::string_ref, T>::value>::type
void
insert(boost::string_ref name, T const& value) insert(boost::string_ref name, T const& value)
{ {
insert(name, insert(name,
@@ -414,7 +413,7 @@ public:
/** Replace a field value. /** Replace a field value.
The current field value, if any, is removed. Then the The current field value, if any, is removed. Then the
specified value is inserted as if by insert(field, value). specified value is inserted as if by `insert(field, value)`.
*/ */
void void
replace(boost::string_ref const& name, replace(boost::string_ref const& name,
@@ -423,12 +422,11 @@ public:
/** Replace a field value. /** Replace a field value.
The current field value, if any, is removed. Then the The current field value, if any, is removed. Then the
specified value is inserted as if by insert(field, value). specified value is inserted as if by `insert(field, value)`.
*/ */
template<class T, template<class T>
class = typename std::enable_if< typename std::enable_if<
! std::is_constructible<boost::string_ref, T>::value>::type> ! std::is_constructible<boost::string_ref, T>::value>::type
void
replace(boost::string_ref const& name, T const& value) replace(boost::string_ref const& name, T const& value)
{ {
replace(name, replace(name,