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) { ...@@ -107,8 +107,7 @@ make_unique(const size_t n) {
// Disallows 'make_unique<T[10]>()'. (N3690 s20.9.1.4 p5) // Disallows 'make_unique<T[10]>()'. (N3690 s20.9.1.4 p5)
template <typename T, typename... Args> template <typename T, typename... Args>
typename std::enable_if< typename std::enable_if<std::extent<T>::value != 0, std::unique_ptr<T>>::type
std::extent<T>::value != 0, std::unique_ptr<T>>::type
make_unique(Args&&...) = delete; make_unique(Args&&...) = delete;
#endif #endif
...@@ -133,7 +132,7 @@ make_unique(Args&&...) = delete; ...@@ -133,7 +132,7 @@ make_unique(Args&&...) = delete;
* buf = nullptr; // calls BIO_free(buf.get()) * buf = nullptr; // calls BIO_free(buf.get())
*/ */
template <typename T, void(*f)(T*)> template <typename T, void (*f)(T*)>
struct static_function_deleter { struct static_function_deleter {
void operator()(T* t) const { void operator()(T* t) const {
f(t); f(t);
...@@ -195,7 +194,7 @@ template <> ...@@ -195,7 +194,7 @@ template <>
struct lift_void_to_char<void> { struct lift_void_to_char<void> {
using type = char; using type = char;
}; };
} } // namespace detail
/** /**
* SysAllocator * SysAllocator
...@@ -494,8 +493,7 @@ struct AllocatorHasTrivialDeallocate<CxxAllocatorAdaptor<T, Alloc>> ...@@ -494,8 +493,7 @@ struct AllocatorHasTrivialDeallocate<CxxAllocatorAdaptor<T, Alloc>>
* *
* To be removed once C++17 becomes a minimum requirement for folly. * To be removed once C++17 becomes a minimum requirement for folly.
*/ */
#if __cplusplus >= 201700L || \ #if __cplusplus >= 201700L || __cpp_lib_enable_shared_from_this >= 201603L
__cpp_lib_enable_shared_from_this >= 201603L
// Guaranteed to have std::enable_shared_from_this::weak_from_this(). Prefer // Guaranteed to have std::enable_shared_from_this::weak_from_this(). Prefer
// type alias over our own class. // type alias over our own class.
...@@ -539,14 +537,14 @@ class enable_shared_from_this : public std::enable_shared_from_this<T> { ...@@ -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 // std::enable_shared_from_this<T>::weak_from_this() if available. Falls
// back to std::enable_shared_from_this<T>::shared_from_this() otherwise. // back to std::enable_shared_from_this<T>::shared_from_this() otherwise.
template <typename U> template <typename U>
auto weak_from_this_(std::enable_shared_from_this<U>* base_ptr) auto weak_from_this_(std::enable_shared_from_this<U>* base_ptr) noexcept
noexcept -> decltype(base_ptr->weak_from_this()) { -> decltype(base_ptr->weak_from_this()) {
return base_ptr->weak_from_this(); return base_ptr->weak_from_this();
} }
template <typename U> template <typename U>
auto weak_from_this_(std::enable_shared_from_this<U> const* base_ptr) auto weak_from_this_(std::enable_shared_from_this<U> const* base_ptr) const
const noexcept -> decltype(base_ptr->weak_from_this()) { noexcept -> decltype(base_ptr->weak_from_this()) {
return 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) { ...@@ -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 // 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 // work with libstdc++ >= 20150123. Feel free to add other standard library
// versions where the behavior is known. // versions where the behavior is known.
#if __cplusplus >= 201700L || \ #if __cplusplus >= 201700L || __GLIBCXX__ >= 20150123L
__GLIBCXX__ >= 20150123L
C stack_resident; C stack_resident;
ASSERT_THROW(stack_resident.shared_from_this(), std::bad_weak_ptr); ASSERT_THROW(stack_resident.shared_from_this(), std::bad_weak_ptr);
ASSERT_TRUE(stack_resident.weak_from_this().expired()); ASSERT_TRUE(stack_resident.weak_from_this().expired());
...@@ -198,10 +197,12 @@ TEST(enable_shared_from_this, compatible_with_std_enable_shared_from_this) { ...@@ -198,10 +197,12 @@ TEST(enable_shared_from_this, compatible_with_std_enable_shared_from_this) {
class C_folly : public folly::enable_shared_from_this<C_folly> {}; class C_folly : public folly::enable_shared_from_this<C_folly> {};
static_assert( static_assert(
noexcept(std::declval<C_std>().shared_from_this()) == noexcept(std::declval<C_std>().shared_from_this()) ==
noexcept(std::declval<C_folly>().shared_from_this()), ""); noexcept(std::declval<C_folly>().shared_from_this()),
"");
static_assert( static_assert(
noexcept(std::declval<C_std const>().shared_from_this()) == noexcept(std::declval<C_std const>().shared_from_this()) ==
noexcept(std::declval<C_folly 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>().weak_from_this()), "");
static_assert(noexcept(std::declval<C_folly const>().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