mirror of
https://github.com/boostorg/beast.git
synced 2025-08-03 14:54:32 +02:00
is_file is in file_base.hpp (API Change):
* The metafunction `is_file` is part of file_base.hpp Actions Required * Include file_base.hpp as needed
This commit is contained in:
@@ -10,10 +10,12 @@ Version 210:
|
||||
API Changes:
|
||||
|
||||
* Stream traits are now in stream_traits.hpp
|
||||
* `is_file` is now in file_base.hpp
|
||||
|
||||
Actions Required:
|
||||
|
||||
* Include the file stream_traits.hpp as needed
|
||||
* Include stream_traits.hpp as needed
|
||||
* Include file_base.hpp as needed
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
@@ -25,7 +25,7 @@ New websocket-chat-multi example
|
||||
]
|
||||
|
||||
[tip
|
||||
The namespace alias `net` is now used throughout for `boost::asio`.
|
||||
The namespace alias `net` is used throughout for `boost::asio`.
|
||||
]
|
||||
|
||||
[*New Features]
|
||||
@@ -113,23 +113,28 @@ New websocket-chat-multi example
|
||||
`is_async_stream`,
|
||||
`is_async_read_stream`, and
|
||||
`is_async_write_stream`
|
||||
are now located in stream_traits.hpp.
|
||||
are in stream_traits.hpp.
|
||||
['Actions Required]: Include stream_traits.hpp as needed.
|
||||
|
||||
* Metafunction
|
||||
`is_file`
|
||||
is in file_base.hpp.
|
||||
['Actions Required]: Include file_base.hpp as needed.
|
||||
|
||||
* `flat_static_buffer::reset()`
|
||||
is deprecated.
|
||||
['Actions Required]:
|
||||
* call
|
||||
`clear()` instead.
|
||||
|
||||
* `buffers_adapter` is now spelled
|
||||
* `buffers_adapter` is spelled
|
||||
`buffers_adaptor`.
|
||||
['Actions Required]:
|
||||
* Replace `buffers_adapter` with
|
||||
`buffers_adaptor`,
|
||||
or define `BOOST_BEAST_ALLOW_DEPRECATED`.
|
||||
|
||||
* `buffers` is now spelled
|
||||
* `buffers` is spelled
|
||||
`make_printable`.
|
||||
['Actions Required]:
|
||||
* Replace `buffers` with
|
||||
|
@@ -11,7 +11,9 @@
|
||||
#define BOOST_BEAST_CORE_FILE_BASE_HPP
|
||||
|
||||
#include <boost/beast/core/detail/config.hpp>
|
||||
#include <boost/beast/core/string.hpp>
|
||||
#include <boost/beast/core/error.hpp>
|
||||
#include <boost/type_traits/make_void.hpp>
|
||||
#include <type_traits>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
@@ -93,6 +95,69 @@ enum class file_mode
|
||||
append_existing
|
||||
};
|
||||
|
||||
/** Determine if `T` meets the requirements of @b File.
|
||||
|
||||
Metafunctions are used to perform compile time checking of template
|
||||
types. This type will be `std::true_type` if `T` meets the requirements,
|
||||
else the type will be `std::false_type`.
|
||||
|
||||
@par Example
|
||||
|
||||
Use with `static_assert`:
|
||||
|
||||
@code
|
||||
template<class File>
|
||||
void f(File& file)
|
||||
{
|
||||
static_assert(is_file<File>::value,
|
||||
"File requirements not met");
|
||||
...
|
||||
@endcode
|
||||
|
||||
Use with `std::enable_if` (SFINAE):
|
||||
|
||||
@code
|
||||
template<class File>
|
||||
typename std::enable_if<is_file<File>::value>::type
|
||||
f(File& file);
|
||||
@endcode
|
||||
*/
|
||||
#if BOOST_BEAST_DOXYGEN
|
||||
template<class T>
|
||||
struct is_file : std::integral_constant<bool, ...>{};
|
||||
#else
|
||||
template<class T, class = void>
|
||||
struct is_file : std::false_type {};
|
||||
|
||||
template<class T>
|
||||
struct is_file<T, boost::void_t<decltype(
|
||||
std::declval<bool&>() = std::declval<T const&>().is_open(),
|
||||
std::declval<T&>().close(std::declval<error_code&>()),
|
||||
std::declval<T&>().open(
|
||||
std::declval<char const*>(),
|
||||
std::declval<file_mode>(),
|
||||
std::declval<error_code&>()),
|
||||
std::declval<std::uint64_t&>() = std::declval<T&>().size(
|
||||
std::declval<error_code&>()),
|
||||
std::declval<std::uint64_t&>() = std::declval<T&>().pos(
|
||||
std::declval<error_code&>()),
|
||||
std::declval<T&>().seek(
|
||||
std::declval<std::uint64_t>(),
|
||||
std::declval<error_code&>()),
|
||||
std::declval<std::size_t&>() = std::declval<T&>().read(
|
||||
std::declval<void*>(),
|
||||
std::declval<std::size_t>(),
|
||||
std::declval<error_code&>()),
|
||||
std::declval<std::size_t&>() = std::declval<T&>().write(
|
||||
std::declval<void const*>(),
|
||||
std::declval<std::size_t>(),
|
||||
std::declval<error_code&>())
|
||||
)>> : std::integral_constant<bool,
|
||||
std::is_default_constructible<T>::value &&
|
||||
std::is_destructible<T>::value
|
||||
> {};
|
||||
#endif
|
||||
|
||||
} // beast
|
||||
} // boost
|
||||
|
||||
|
@@ -56,75 +56,6 @@ using is_completion_handler = std::integral_constant<bool,
|
||||
detail::is_invocable<T, Signature>::value>;
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//
|
||||
// File concepts
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** Determine if `T` meets the requirements of @b File.
|
||||
|
||||
Metafunctions are used to perform compile time checking of template
|
||||
types. This type will be `std::true_type` if `T` meets the requirements,
|
||||
else the type will be `std::false_type`.
|
||||
|
||||
@par Example
|
||||
|
||||
Use with `static_assert`:
|
||||
|
||||
@code
|
||||
template<class File>
|
||||
void f(File& file)
|
||||
{
|
||||
static_assert(is_file<File>::value,
|
||||
"File requirements not met");
|
||||
...
|
||||
@endcode
|
||||
|
||||
Use with `std::enable_if` (SFINAE):
|
||||
|
||||
@code
|
||||
template<class File>
|
||||
typename std::enable_if<is_file<File>::value>::type
|
||||
f(File& file);
|
||||
@endcode
|
||||
*/
|
||||
#if BOOST_BEAST_DOXYGEN
|
||||
template<class T>
|
||||
struct is_file : std::integral_constant<bool, ...>{};
|
||||
#else
|
||||
template<class T, class = void>
|
||||
struct is_file : std::false_type {};
|
||||
|
||||
template<class T>
|
||||
struct is_file<T, detail::void_t<decltype(
|
||||
std::declval<bool&>() = std::declval<T const&>().is_open(),
|
||||
std::declval<T&>().close(std::declval<error_code&>()),
|
||||
std::declval<T&>().open(
|
||||
std::declval<char const*>(),
|
||||
std::declval<file_mode>(),
|
||||
std::declval<error_code&>()),
|
||||
std::declval<std::uint64_t&>() = std::declval<T&>().size(
|
||||
std::declval<error_code&>()),
|
||||
std::declval<std::uint64_t&>() = std::declval<T&>().pos(
|
||||
std::declval<error_code&>()),
|
||||
std::declval<T&>().seek(
|
||||
std::declval<std::uint64_t>(),
|
||||
std::declval<error_code&>()),
|
||||
std::declval<std::size_t&>() = std::declval<T&>().read(
|
||||
std::declval<void*>(),
|
||||
std::declval<std::size_t>(),
|
||||
std::declval<error_code&>()),
|
||||
std::declval<std::size_t&>() = std::declval<T&>().write(
|
||||
std::declval<void const*>(),
|
||||
std::declval<std::size_t>(),
|
||||
std::declval<error_code&>())
|
||||
)>> : std::integral_constant<bool,
|
||||
std::is_default_constructible<T>::value &&
|
||||
std::is_destructible<T>::value
|
||||
> {};
|
||||
#endif
|
||||
|
||||
} // beast
|
||||
} // boost
|
||||
|
||||
|
@@ -13,7 +13,6 @@
|
||||
#include <boost/beast/core/detail/config.hpp>
|
||||
#include <boost/beast/core/error.hpp>
|
||||
#include <boost/beast/core/file_base.hpp>
|
||||
#include <boost/beast/core/type_traits.hpp>
|
||||
#include <boost/beast/http/message.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
|
@@ -45,6 +45,7 @@ add_executable (tests-beast-core
|
||||
dynamic_buffer_ref.cpp
|
||||
error.cpp
|
||||
file.cpp
|
||||
file_base.cpp
|
||||
file_posix.cpp
|
||||
file_stdio.cpp
|
||||
file_win32.cpp
|
||||
|
@@ -33,6 +33,7 @@ local SOURCES =
|
||||
dynamic_buffer_ref.cpp
|
||||
error.cpp
|
||||
file.cpp
|
||||
file_base.cpp
|
||||
file_posix.cpp
|
||||
file_stdio.cpp
|
||||
file_win32.cpp
|
||||
|
11
test/beast/core/file_base.cpp
Normal file
11
test/beast/core/file_base.cpp
Normal file
@@ -0,0 +1,11 @@
|
||||
//
|
||||
// Copyright (c) 2019 Vinnie Falco (vinnie dot falco at gmail dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// Official repository: https://github.com/boostorg/beast
|
||||
//
|
||||
|
||||
// Test that header file is self-contained.
|
||||
#include <boost/beast/core/file_base.hpp>
|
@@ -10,8 +10,9 @@
|
||||
#ifndef BOOST_BEAST_FILE_TEST_HPP
|
||||
#define BOOST_BEAST_FILE_TEST_HPP
|
||||
|
||||
#include <boost/beast/core/type_traits.hpp>
|
||||
#include <boost/beast/_experimental/unit_test/suite.hpp>
|
||||
#include <boost/beast/core/string.hpp>
|
||||
#include <boost/beast/core/file_base.hpp>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
#include <cstdio>
|
||||
|
@@ -14,6 +14,7 @@
|
||||
#include <boost/beast/core/flat_buffer.hpp>
|
||||
#include <boost/beast/core/flat_static_buffer.hpp>
|
||||
#include <boost/beast/core/multi_buffer.hpp>
|
||||
#include <boost/beast/core/string.hpp>
|
||||
#include <boost/beast/_experimental/unit_test/suite.hpp>
|
||||
#include <ostream>
|
||||
|
||||
|
Reference in New Issue
Block a user