Commit 091165ea authored by Nathan Bronson's avatar Nathan Bronson Committed by Facebook Github Bot

clang-format Memory.h and its test

Reviewed By: yfeldblum

Differential Revision: D8208046

fbshipit-source-id: 58ae8a1df7fedd7bb8ec63bcb51c82ec7fb3c9e8
parent 40a62d63
......@@ -107,8 +107,7 @@ make_unique(const size_t n) {
// Disallows 'make_unique<T[10]>()'. (N3690 s20.9.1.4 p5)
template <typename T, typename... Args>
typename std::enable_if<
std::extent<T>::value != 0, std::unique_ptr<T>>::type
typename std::enable_if<std::extent<T>::value != 0, std::unique_ptr<T>>::type
make_unique(Args&&...) = delete;
#endif
......@@ -133,7 +132,7 @@ make_unique(Args&&...) = delete;
* buf = nullptr; // calls BIO_free(buf.get())
*/
template <typename T, void(*f)(T*)>
template <typename T, void (*f)(T*)>
struct static_function_deleter {
void operator()(T* t) const {
f(t);
......@@ -195,7 +194,7 @@ template <>
struct lift_void_to_char<void> {
using type = char;
};
}
} // namespace detail
/**
* SysAllocator
......@@ -494,8 +493,7 @@ struct AllocatorHasTrivialDeallocate<CxxAllocatorAdaptor<T, Alloc>>
*
* To be removed once C++17 becomes a minimum requirement for folly.
*/
#if __cplusplus >= 201700L || \
__cpp_lib_enable_shared_from_this >= 201603L
#if __cplusplus >= 201700L || __cpp_lib_enable_shared_from_this >= 201603L
// Guaranteed to have std::enable_shared_from_this::weak_from_this(). Prefer
// type alias over our own class.
......@@ -539,14 +537,14 @@ class enable_shared_from_this : public std::enable_shared_from_this<T> {
// std::enable_shared_from_this<T>::weak_from_this() if available. Falls
// back to std::enable_shared_from_this<T>::shared_from_this() otherwise.
template <typename U>
auto weak_from_this_(std::enable_shared_from_this<U>* base_ptr)
noexcept -> decltype(base_ptr->weak_from_this()) {
auto weak_from_this_(std::enable_shared_from_this<U>* base_ptr) noexcept
-> decltype(base_ptr->weak_from_this()) {
return base_ptr->weak_from_this();
}
template <typename U>
auto weak_from_this_(std::enable_shared_from_this<U> const* base_ptr)
const noexcept -> decltype(base_ptr->weak_from_this()) {
auto weak_from_this_(std::enable_shared_from_this<U> const* base_ptr) const
noexcept -> decltype(base_ptr->weak_from_this()) {
return base_ptr->weak_from_this();
}
......
......@@ -184,8 +184,7 @@ static void test_enable_shared_from_this(std::shared_ptr<C> sp) {
// shared_ptr. Undefined in C++14 but well-defined in C++17. Also known to
// work with libstdc++ >= 20150123. Feel free to add other standard library
// versions where the behavior is known.
#if __cplusplus >= 201700L || \
__GLIBCXX__ >= 20150123L
#if __cplusplus >= 201700L || __GLIBCXX__ >= 20150123L
C stack_resident;
ASSERT_THROW(stack_resident.shared_from_this(), std::bad_weak_ptr);
ASSERT_TRUE(stack_resident.weak_from_this().expired());
......@@ -197,11 +196,13 @@ TEST(enable_shared_from_this, compatible_with_std_enable_shared_from_this) {
class C_std : public std::enable_shared_from_this<C_std> {};
class C_folly : public folly::enable_shared_from_this<C_folly> {};
static_assert(
noexcept(std::declval<C_std>().shared_from_this()) ==
noexcept(std::declval<C_folly>().shared_from_this()), "");
noexcept(std::declval<C_std>().shared_from_this()) ==
noexcept(std::declval<C_folly>().shared_from_this()),
"");
static_assert(
noexcept(std::declval<C_std const>().shared_from_this()) ==
noexcept(std::declval<C_folly const>().shared_from_this()), "");
noexcept(std::declval<C_std const>().shared_from_this()) ==
noexcept(std::declval<C_folly const>().shared_from_this()),
"");
static_assert(noexcept(std::declval<C_folly>().weak_from_this()), "");
static_assert(noexcept(std::declval<C_folly const>().weak_from_this()), "");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment