Skip to content

Commit

Permalink
fix code style
Browse files Browse the repository at this point in the history
  • Loading branch information
oathdruid committed Aug 6, 2024
1 parent 6cca06b commit 53377cd
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 29 deletions.
16 changes: 10 additions & 6 deletions src/babylon/any.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

#include "babylon/type_traits.h"

#include <memory> // std::unique_ptr

// clang-format off
#include "babylon/protect.h"
// clang-format on

#include <memory> // std::unique_ptr

BABYLON_NAMESPACE_BEGIN

Expand Down Expand Up @@ -227,8 +229,8 @@ class Any {
};

template <typename T>
struct TypeDescriptor<
T, typename ::std::enable_if<::std::is_copy_constructible<T>::value>::type>
struct TypeDescriptor<T, typename ::std::enable_if<
::std::is_copy_constructible<T>::value>::type>
: public TypeDescriptor<T, int> {
static void copy_constructor(void* ptr, const void* object) noexcept;
static void* copy_creater(const void* object) noexcept;
Expand All @@ -243,8 +245,8 @@ class Any {
};

template <typename T>
struct TypeDescriptor<
T, typename ::std::enable_if<!::std::is_copy_constructible<T>::value>::type>
struct TypeDescriptor<T, typename ::std::enable_if<
!::std::is_copy_constructible<T>::value>::type>
: public TypeDescriptor<T, int> {
static void copy_constructor(void* ptr, const void* object) noexcept;
static void* copy_creater(const void* object) noexcept;
Expand Down Expand Up @@ -305,6 +307,8 @@ class Any {

BABYLON_NAMESPACE_END

// clang-format off
#include "babylon/unprotect.h"
// clang-format on

#include "babylon/any.hpp"
30 changes: 15 additions & 15 deletions src/babylon/any.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
#include BABYLON_EXTERNAL(absl/base/optimization.h) // ABSL_PREDICT_FALSE
// clang-format on

#include <cassert> // ::assert

#include "babylon/protect.h"

#include <cassert> // ::assert

BABYLON_NAMESPACE_BEGIN

////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -39,12 +39,12 @@ Any::Meta Any::TypeDescriptor<T, E>::meta_for_inplace_non_trivial {
#if __cplusplus < 201703L
template <typename T>
constexpr Any::Descriptor Any::TypeDescriptor<
T,
typename ::std::enable_if<::std::is_copy_constructible<T>::value>::type>::descriptor;
T, typename ::std::enable_if<
::std::is_copy_constructible<T>::value>::type>::descriptor;
template <typename T>
constexpr Any::Descriptor Any::TypeDescriptor<
T, typename ::std::enable_if<!::std::is_copy_constructible<T>::value>::type>::
descriptor;
T, typename ::std::enable_if<
!::std::is_copy_constructible<T>::value>::type>::descriptor;
#endif // __cplusplus < 201703L

template <typename T, typename E>
Expand All @@ -58,31 +58,31 @@ void Any::TypeDescriptor<T, E>::deleter(void* object) noexcept {
}

template <typename T>
void Any::TypeDescriptor<
T, typename ::std::enable_if<::std::is_copy_constructible<T>::value>::type>::
void Any::TypeDescriptor<T, typename ::std::enable_if<
::std::is_copy_constructible<T>::value>::type>::
copy_constructor(void* ptr, const void* object) noexcept {
new (ptr) T(*reinterpret_cast<const T*>(object));
}

template <typename T>
void Any::TypeDescriptor<
T, typename ::std::enable_if<!::std::is_copy_constructible<T>::value>::type>::
copy_constructor(void*, const void*) noexcept {
T, typename ::std::enable_if<!::std::is_copy_constructible<T>::value>::
type>::copy_constructor(void*, const void*) noexcept {
assert(false &&
"try copy non-copyable instance by copy an babylon::Any instance");
}

template <typename T>
void* Any::TypeDescriptor<
T, typename ::std::enable_if<::std::is_copy_constructible<T>::value>::type>::
copy_creater(const void* object) noexcept {
T, typename ::std::enable_if<::std::is_copy_constructible<T>::value>::
type>::copy_creater(const void* object) noexcept {
return new T(*reinterpret_cast<const T*>(object));
}

template <typename T>
void* Any::TypeDescriptor<
T, typename ::std::enable_if<!::std::is_copy_constructible<T>::value>::type>::
copy_creater(const void*) noexcept {
T, typename ::std::enable_if<!::std::is_copy_constructible<T>::value>::
type>::copy_creater(const void*) noexcept {
assert(false &&
"try copy non-copyable instance by copy an babylon::Any instance");
return nullptr;
Expand Down Expand Up @@ -421,7 +421,7 @@ inline const void* Any::const_raw_pointer() const noexcept {
}

template <typename T,
typename ::std::enable_if< ::std::is_integral<T>::value, int>::type>
typename ::std::enable_if<::std::is_integral<T>::value, int>::type>
inline void Any::construct_inplace(T&& value) noexcept {
_holder.uint64_v = value;
}
Expand Down
4 changes: 2 additions & 2 deletions src/babylon/logging/async_file_appender.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#include "babylon/logging/async_file_appender.h"

#include "babylon/protect.h"

#include <fcntl.h>
#include <sys/mman.h>
#include <sys/stat.h>

#include "babylon/protect.h"

BABYLON_NAMESPACE_BEGIN

////////////////////////////////////////////////////////////////////////////////
Expand Down
2 changes: 2 additions & 0 deletions src/babylon/logging/log_severity.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

#include "babylon/string_view.h" // StringView

// clang-format off
#include "babylon/protect.h"
// clang-format on

BABYLON_NAMESPACE_BEGIN

Expand Down
10 changes: 6 additions & 4 deletions test/concurrent/test_sched_interface.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#include <babylon/concurrent/sched_interface.h>
#include "babylon/concurrent/sched_interface.h"

#include <gtest/gtest.h>
// clang-format off
#include "babylon/protect.h"
// clang-format on

#include <future> // ::std::async
#include "gtest/gtest.h"

#include "babylon/protect.h"
#include <future> // ::std::async

using ::babylon::Futex;
using ::babylon::SchedInterface;
Expand Down
3 changes: 1 addition & 2 deletions test/test_mlock.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "babylon/mlock.h"

#include "babylon/logging/logger.h"
#include "babylon/mlock.h"

// clang-format off
#include BABYLON_EXTERNAL(absl/base/config.h)
Expand Down

0 comments on commit 53377cd

Please sign in to comment.