Skip to content

Commit

Permalink
style: Apply clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
Tradias committed Sep 27, 2024
1 parent aed9853 commit 4e09ba4
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 45 deletions.
5 changes: 2 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,8 @@ unset(CNTGS_SOURCE_FILES)
# installation
if(CNTGS_INSTALL)
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/generated/cntgsConfigVersion.cmake" ARCH_INDEPENDENT
COMPATIBILITY SameMinorVersion)
write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/generated/cntgsConfigVersion.cmake" ARCH_INDEPENDENT
COMPATIBILITY SameMinorVersion)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/generated/cntgsConfigVersion.cmake" DESTINATION share/cntgs)

include(GNUInstallDirs)
Expand Down
12 changes: 5 additions & 7 deletions src/cntgs/detail/elementLocator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class ElementLocator : public BaseElementLocator
std::size_t new_max_element_count, std::byte* new_memory_begin) noexcept
{
trivially_copy_into(old_locator, old_max_element_count, old_memory_begin, new_max_element_count,
new_memory_begin);
new_memory_begin);
}

template <class... Args>
Expand Down Expand Up @@ -153,8 +153,7 @@ class ElementLocator : public BaseElementLocator
void trivially_copy_into(std::size_t old_max_element_count, std::byte* CNTGS_RESTRICT old_memory_begin,
std::size_t new_max_element_count, std::byte* CNTGS_RESTRICT new_memory_begin) noexcept
{
trivially_copy_into(*this, old_max_element_count, old_memory_begin, new_max_element_count,
new_memory_begin);
trivially_copy_into(*this, old_max_element_count, old_memory_begin, new_max_element_count, new_memory_begin);
}

static constexpr auto calculate_new_memory_size(std::size_t max_element_count, std::size_t varying_size_bytes,
Expand Down Expand Up @@ -281,8 +280,7 @@ class ElementLocator<true, Parameter...> : public BaseAllFixedSizeElementLocator
template <class... Args>
auto emplace_at(std::size_t index, const std::byte*, const FixedSizesArray& fixed_sizes, Args&&... args)
{
return ElementTraits::emplace_at_aliased(element_address(index, {}), fixed_sizes,
std::forward<Args>(args)...);
return ElementTraits::emplace_at_aliased(element_address(index, {}), fixed_sizes, std::forward<Args>(args)...);
}

void trivially_copy_into(std::size_t, const std::byte*, std::size_t, std::byte* new_memory_begin) noexcept
Expand All @@ -294,8 +292,8 @@ class ElementLocator<true, Parameter...> : public BaseAllFixedSizeElementLocator
const FixedSizesArray&) noexcept
{
constexpr auto ALIGNMENT_OVERHEAD = ElementTraits::template ParameterTraitsAt<0>::ALIGNMENT - 1;
return varying_size_bytes + stride_ * max_element_count +
ElementLocator::reserved_bytes(max_element_count) + ALIGNMENT_OVERHEAD;
return varying_size_bytes + stride_ * max_element_count + ElementLocator::reserved_bytes(max_element_count) +
ALIGNMENT_OVERHEAD;
}

private:
Expand Down
10 changes: 5 additions & 5 deletions src/cntgs/detail/iterator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ constexpr auto operator_arrow_produces_pointer_to_iterator_reference_type() noex

template <class I>
inline constexpr auto CONTIGUOUS_ITERATOR_V =
detail::DerivedFrom<typename std::iterator_traits<I>::iterator_category, std::random_access_iterator_tag>&&
std::is_lvalue_reference_v<typename std::iterator_traits<I>::reference>&&
std::is_same_v<typename std::iterator_traits<I>::value_type,
detail::RemoveCvrefT<typename std::iterator_traits<I>::reference>>&&
detail::operator_arrow_produces_pointer_to_iterator_reference_type<I>();
detail::DerivedFrom<typename std::iterator_traits<I>::iterator_category, std::random_access_iterator_tag> &&
std::is_lvalue_reference_v<typename std::iterator_traits<I>::reference> &&
std::is_same_v<typename std::iterator_traits<I>::value_type,
detail::RemoveCvrefT<typename std::iterator_traits<I>::reference>> &&
detail::operator_arrow_produces_pointer_to_iterator_reference_type<I>();
} // namespace cntgs::detail

#endif // CNTGS_DETAIL_ITERATOR_HPP
4 changes: 2 additions & 2 deletions src/cntgs/detail/memory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ auto uninitialized_range_construct(Range&& CNTGS_RESTRICT range, TargetType* CNT
}

template <bool IgnoreAliasing, class TargetType, class Range>
auto uninitialized_construct(Range&& CNTGS_RESTRICT range, TargetType* CNTGS_RESTRICT address, std::size_t)
-> std::enable_if_t<detail::IsRange<Range>::value, std::byte*>
auto uninitialized_construct(Range&& CNTGS_RESTRICT range, TargetType* CNTGS_RESTRICT address,
std::size_t) -> std::enable_if_t<detail::IsRange<Range>::value, std::byte*>
{
return detail::uninitialized_range_construct<IgnoreAliasing>(std::forward<Range>(range), address);
}
Expand Down
10 changes: 5 additions & 5 deletions src/cntgs/detail/typeTraits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ concept DerivedFrom = std::derived_from<Derived, Base>;
#else
template <class Derived, class Base>
inline constexpr auto DerivedFrom =
std::is_base_of_v<Base, Derived>&& std::is_convertible_v<const volatile Derived*, const volatile Base*>;
std::is_base_of_v<Base, Derived> && std::is_convertible_v<const volatile Derived*, const volatile Base*>;
#endif

#ifdef __cpp_lib_remove_cvref
Expand Down Expand Up @@ -148,13 +148,13 @@ template <class T>
inline constexpr auto IS_NOTRHOW_EQUALITY_COMPARABLE = noexcept(std::declval<const T&>() == std::declval<const T&>());

template <class T>
inline constexpr auto IS_NOTRHOW_LEXICOGRAPHICAL_COMPARABLE = noexcept(std::declval<const T&>() <
std::declval<const T&>());
inline constexpr auto IS_NOTRHOW_LEXICOGRAPHICAL_COMPARABLE =
noexcept(std::declval<const T&>() < std::declval<const T&>());

template <class T, class U>
inline constexpr auto MEMCPY_COMPATIBLE =
detail::EQUAL_SIZEOF<T, U>&& std::is_trivially_copyable_v<T>&& std::is_trivially_copyable_v<U>&&
std::is_floating_point_v<T> == std::is_floating_point_v<U>;
detail::EQUAL_SIZEOF<T, U> && std::is_trivially_copyable_v<T> && std::is_trivially_copyable_v<U> &&
std::is_floating_point_v<T> == std::is_floating_point_v<U>;

// Implementation taken from MSVC _Can_memcmp_elements
template <class T, class U = T,
Expand Down
4 changes: 2 additions & 2 deletions src/cntgs/element.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,8 @@ class BasicContiguousElement
StorageType new_memory{other.memory_.size(), get_allocator()};
destruct();
reference_.tuple_ = store_and_load(other.reference_, other_size_in_bytes,
BasicContiguousElement::memory_begin(new_memory))
.tuple_;
BasicContiguousElement::memory_begin(new_memory))
.tuple_;
memory_ = std::move(new_memory);
}
else
Expand Down
10 changes: 2 additions & 8 deletions src/cntgs/iterator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,7 @@ class ContiguousVectorIterator
return copy;
}

[[nodiscard]] constexpr difference_type operator+(ContiguousVectorIterator it) const noexcept
{
return i_ + it.i_;
}
[[nodiscard]] constexpr difference_type operator+(ContiguousVectorIterator it) const noexcept { return i_ + it.i_; }

constexpr ContiguousVectorIterator& operator+=(difference_type diff) noexcept
{
Expand All @@ -136,10 +133,7 @@ class ContiguousVectorIterator
return copy;
}

[[nodiscard]] constexpr difference_type operator-(ContiguousVectorIterator it) const noexcept
{
return i_ - it.i_;
}
[[nodiscard]] constexpr difference_type operator-(ContiguousVectorIterator it) const noexcept { return i_ - it.i_; }

constexpr ContiguousVectorIterator& operator-=(difference_type diff) noexcept
{
Expand Down
2 changes: 1 addition & 1 deletion src/cntgs/span.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ struct Span
Span(Span&& other) = default;

Span& operator=(const Span& other) = default;

Span& operator=(Span&& other) = default;

constexpr Span(iterator first, iterator last) noexcept : first_(first), last_(last) {}
Expand Down
19 changes: 7 additions & 12 deletions src/cntgs/vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ class BasicContiguousVector<cntgs::Options<Option...>, Parameter...>
explicit BasicContiguousVector(cntgs::TypeErasedVector&& vector) noexcept
: max_element_count_(vector.max_element_count),
memory_(vector.memory, vector.memory_size,
*std::launder(reinterpret_cast<allocator_type*>(&vector.allocator))),
*std::launder(reinterpret_cast<allocator_type*>(&vector.allocator))),
locator_(*std::launder(reinterpret_cast<ElementLocator*>(&vector.locator)),
detail::convert_array_to_size<ListTraits::CONTIGUOUS_FIXED_SIZE_COUNT>(vector.fixed_sizes))
detail::convert_array_to_size<ListTraits::CONTIGUOUS_FIXED_SIZE_COUNT>(vector.fixed_sizes))
{
vector.is_memory_owned.value_ = false;
}
Expand Down Expand Up @@ -259,10 +259,7 @@ class BasicContiguousVector<cntgs::Options<Option...>, Parameter...>

[[nodiscard]] constexpr bool empty() const noexcept { return locator_->empty(memory_.get()); }

[[nodiscard]] constexpr std::byte* data() noexcept
{
return locator_->element_address({}, memory_.get());
}
[[nodiscard]] constexpr std::byte* data() noexcept { return locator_->element_address({}, memory_.get()); }

[[nodiscard]] constexpr const std::byte* data() const noexcept
{
Expand Down Expand Up @@ -377,8 +374,8 @@ class BasicContiguousVector<cntgs::Options<Option...>, Parameter...>

void grow(size_type new_max_element_count, size_type new_varying_size_bytes)
{
const auto new_memory_size = locator_->calculate_new_memory_size(
new_max_element_count, new_varying_size_bytes, locator_.fixed_sizes());
const auto new_memory_size =
locator_->calculate_new_memory_size(new_max_element_count, new_varying_size_bytes, locator_.fixed_sizes());
StorageType new_memory{new_memory_size, get_allocator()};
BasicContiguousVector::insert_into<true>(*locator_, new_max_element_count, new_memory.get(), *this);
max_element_count_ = new_max_element_count;
Expand Down Expand Up @@ -460,8 +457,7 @@ class BasicContiguousVector<cntgs::Options<Option...>, Parameter...>
template <std::size_t... I>
void emplace_at(std::size_t i, const reference& element, std::index_sequence<I...>)
{
locator_->emplace_at(i, memory_.get(), locator_.fixed_sizes(),
std::move(cntgs::get<I>(element))...);
locator_->emplace_at(i, memory_.get(), locator_.fixed_sizes(), std::move(cntgs::get<I>(element))...);
ElementTraits::destruct(element);
}

Expand Down Expand Up @@ -501,8 +497,7 @@ class BasicContiguousVector<cntgs::Options<Option...>, Parameter...>
else
{
destruct();
BasicContiguousVector::insert_into(*other_locator, other.max_element_count_, memory_.get(),
other);
BasicContiguousVector::insert_into(*other_locator, other.max_element_count_, memory_.get(), other);
}
max_element_count_ = other.max_element_count_;
locator_ = other_locator;
Expand Down

0 comments on commit 4e09ba4

Please sign in to comment.