Skip to content

Commit

Permalink
change clang-format PointerAlignment to Left
Browse files Browse the repository at this point in the history
This avoids the clang-format inconsistencies related to variadic
pointer and reference parameters with PointerAlignment: Right.
Older clang-format versions format `T&&... a` as `T &&... a`,
but never versions format it as `T &&... a`, while normal
variadic parameters are formatted as `T... a` any time.
This inconsistency is not present for PointerAlignment: Left
  • Loading branch information
upsj committed Sep 1, 2021
1 parent 4046ebc commit 1f476bd
Show file tree
Hide file tree
Showing 640 changed files with 10,352 additions and 10,363 deletions.
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Right
PointerAlignment: Left
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
Expand Down
150 changes: 75 additions & 75 deletions accessor/accessor_helper.hpp

Large diffs are not rendered by default.

90 changes: 47 additions & 43 deletions accessor/accessor_references.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,15 @@ struct has_cast_operator<
template <typename ValueType, typename Ref>
constexpr GKO_ACC_ATTRIBUTES
std::enable_if_t<has_cast_operator<Ref, ValueType>::value, ValueType>
to_value_type(const Ref &ref)
to_value_type(const Ref& ref)
{
return ref.Ref::operator ValueType();
}

template <typename ValueType, typename Ref>
constexpr GKO_ACC_ATTRIBUTES
std::enable_if_t<!has_cast_operator<Ref, ValueType>::value, ValueType>
to_value_type(const Ref &ref)
to_value_type(const Ref& ref)
{
return static_cast<ValueType>(ref);
}
Expand Down Expand Up @@ -126,20 +126,20 @@ struct enable_reference_operators {
#define GKO_ACC_REFERENCE_BINARY_OPERATOR_OVERLOAD(_op) \
friend GKO_ACC_ENABLE_REFERENCE_CONSTEXPR GKO_ACC_INLINE \
GKO_ACC_ATTRIBUTES arithmetic_type \
operator _op(const Reference &ref1, const Reference &ref2) \
operator _op(const Reference& ref1, const Reference& ref2) \
{ \
return to_value_type<arithmetic_type>(ref1) \
_op to_value_type<arithmetic_type>(ref2); \
} \
friend GKO_ACC_ENABLE_REFERENCE_CONSTEXPR GKO_ACC_INLINE \
GKO_ACC_ATTRIBUTES arithmetic_type \
operator _op(const Reference &ref, const arithmetic_type &a) \
operator _op(const Reference& ref, const arithmetic_type& a) \
{ \
return to_value_type<arithmetic_type>(ref) _op a; \
} \
friend GKO_ACC_ENABLE_REFERENCE_CONSTEXPR GKO_ACC_INLINE \
GKO_ACC_ATTRIBUTES arithmetic_type \
operator _op(const arithmetic_type &a, const Reference &ref) \
operator _op(const arithmetic_type& a, const Reference& ref) \
{ \
return a _op to_value_type<arithmetic_type>(ref); \
}
Expand All @@ -153,14 +153,14 @@ struct enable_reference_operators {
#define GKO_ACC_REFERENCE_ASSIGNMENT_OPERATOR_OVERLOAD(_oper, _op) \
friend GKO_ACC_ENABLE_REFERENCE_CONSTEXPR GKO_ACC_INLINE \
GKO_ACC_ATTRIBUTES arithmetic_type \
_oper(Reference &&ref1, const Reference &ref2) \
_oper(Reference&& ref1, const Reference& ref2) \
{ \
return std::move(ref1) = to_value_type<arithmetic_type>(ref1) \
_op to_value_type<arithmetic_type>(ref2); \
} \
friend GKO_ACC_ENABLE_REFERENCE_CONSTEXPR GKO_ACC_INLINE \
GKO_ACC_ATTRIBUTES arithmetic_type \
_oper(Reference &&ref, const arithmetic_type &a) \
_oper(Reference&& ref, const arithmetic_type& a) \
{ \
return std::move(ref) = to_value_type<arithmetic_type>(ref) _op a; \
}
Expand All @@ -174,20 +174,20 @@ struct enable_reference_operators {
#define GKO_ACC_REFERENCE_COMPARISON_OPERATOR_OVERLOAD(_op) \
friend GKO_ACC_ENABLE_REFERENCE_CONSTEXPR GKO_ACC_INLINE \
GKO_ACC_ATTRIBUTES bool \
operator _op(const Reference &ref1, const Reference &ref2) \
operator _op(const Reference& ref1, const Reference& ref2) \
{ \
return to_value_type<arithmetic_type>(ref1) \
_op to_value_type<arithmetic_type>(ref2); \
} \
friend GKO_ACC_ENABLE_REFERENCE_CONSTEXPR GKO_ACC_INLINE \
GKO_ACC_ATTRIBUTES bool \
operator _op(const Reference &ref, const arithmetic_type &a) \
operator _op(const Reference& ref, const arithmetic_type& a) \
{ \
return to_value_type<arithmetic_type>(ref) _op a; \
} \
friend GKO_ACC_ENABLE_REFERENCE_CONSTEXPR GKO_ACC_INLINE \
GKO_ACC_ATTRIBUTES bool \
operator _op(const arithmetic_type &a, const Reference &ref) \
operator _op(const arithmetic_type& a, const Reference& ref) \
{ \
return a _op to_value_type<arithmetic_type>(ref); \
}
Expand All @@ -197,7 +197,7 @@ struct enable_reference_operators {

friend GKO_ACC_ENABLE_REFERENCE_CONSTEXPR GKO_ACC_INLINE GKO_ACC_ATTRIBUTES
arithmetic_type
operator-(const Reference &ref)
operator-(const Reference& ref)
{
return -to_value_type<arithmetic_type>(ref);
}
Expand Down Expand Up @@ -244,50 +244,52 @@ class reduced_storage

// Allow move construction, so perfect forwarding is possible (required
// for `range` support)
reduced_storage(reduced_storage &&) = default;
reduced_storage(reduced_storage&&) = default;

reduced_storage() = delete;

~reduced_storage() = default;

// Forbid copy construction
reduced_storage(const reduced_storage &) = delete;
reduced_storage(const reduced_storage&) = delete;

constexpr explicit GKO_ACC_ATTRIBUTES reduced_storage(
storage_type *const GKO_ACC_RESTRICT ptr)
storage_type* const GKO_ACC_RESTRICT ptr)
: ptr_{ptr}
{}

constexpr GKO_ACC_ATTRIBUTES operator arithmetic_type() const
{
const storage_type *const GKO_ACC_RESTRICT r_ptr = ptr_;
const storage_type* const GKO_ACC_RESTRICT r_ptr = ptr_;
return static_cast<arithmetic_type>(*r_ptr);
}

constexpr GKO_ACC_ATTRIBUTES arithmetic_type
operator=(arithmetic_type val) &&noexcept
operator=(arithmetic_type val) &&
noexcept
{
storage_type *const GKO_ACC_RESTRICT r_ptr = ptr_;
storage_type* const GKO_ACC_RESTRICT r_ptr = ptr_;
*r_ptr = static_cast<storage_type>(val);
return val;
}

constexpr GKO_ACC_ATTRIBUTES arithmetic_type
operator=(const reduced_storage &ref) &&
operator=(const reduced_storage& ref) &&
{
std::move(*this) = static_cast<arithmetic_type>(ref);
return static_cast<arithmetic_type>(*this);
}

constexpr GKO_ACC_ATTRIBUTES arithmetic_type
operator=(reduced_storage &&ref) &&noexcept
operator=(reduced_storage&& ref) &&
noexcept
{
std::move(*this) = static_cast<arithmetic_type>(ref);
return static_cast<arithmetic_type>(*this);
}

private:
storage_type *const GKO_ACC_RESTRICT ptr_;
storage_type* const GKO_ACC_RESTRICT ptr_;
};

// Specialization for const storage_type to prevent `operator=`
Expand All @@ -300,36 +302,36 @@ class reduced_storage<ArithmeticType, const StorageType>
using storage_type = const StorageType;

// Allow move construction, so perfect forwarding is possible
reduced_storage(reduced_storage &&) = default;
reduced_storage(reduced_storage&&) = default;

reduced_storage() = delete;

~reduced_storage() = default;

// Forbid copy construction and move assignment
reduced_storage(const reduced_storage &) = delete;
reduced_storage(const reduced_storage&) = delete;

reduced_storage &operator=(reduced_storage &&) = delete;
reduced_storage& operator=(reduced_storage&&) = delete;

constexpr explicit GKO_ACC_ATTRIBUTES reduced_storage(
storage_type *const GKO_ACC_RESTRICT ptr)
storage_type* const GKO_ACC_RESTRICT ptr)
: ptr_{ptr}
{}

constexpr GKO_ACC_ATTRIBUTES operator arithmetic_type() const
{
const storage_type *const GKO_ACC_RESTRICT r_ptr = ptr_;
const storage_type* const GKO_ACC_RESTRICT r_ptr = ptr_;
return static_cast<arithmetic_type>(*r_ptr);
}

private:
storage_type *const GKO_ACC_RESTRICT ptr_;
storage_type* const GKO_ACC_RESTRICT ptr_;
};


template <typename ArithmeticType, typename StorageType>
constexpr remove_complex_t<ArithmeticType> abs(
const reduced_storage<ArithmeticType, StorageType> &ref)
const reduced_storage<ArithmeticType, StorageType>& ref)
{
using std::abs;
return abs(static_cast<ArithmeticType>(ref));
Expand Down Expand Up @@ -364,50 +366,52 @@ class scaled_reduced_storage
using storage_type = StorageType;

// Allow move construction, so perfect forwarding is possible
scaled_reduced_storage(scaled_reduced_storage &&) = default;
scaled_reduced_storage(scaled_reduced_storage&&) = default;

scaled_reduced_storage() = delete;

~scaled_reduced_storage() = default;

// Forbid copy construction
scaled_reduced_storage(const scaled_reduced_storage &) = delete;
scaled_reduced_storage(const scaled_reduced_storage&) = delete;

constexpr explicit GKO_ACC_ATTRIBUTES scaled_reduced_storage(
storage_type *const GKO_ACC_RESTRICT ptr, arithmetic_type scalar)
storage_type* const GKO_ACC_RESTRICT ptr, arithmetic_type scalar)
: ptr_{ptr}, scalar_{scalar}
{}

constexpr GKO_ACC_ATTRIBUTES operator arithmetic_type() const
{
const storage_type *const GKO_ACC_RESTRICT r_ptr = ptr_;
const storage_type* const GKO_ACC_RESTRICT r_ptr = ptr_;
return static_cast<arithmetic_type>(*r_ptr) * scalar_;
}

constexpr GKO_ACC_ATTRIBUTES arithmetic_type
operator=(arithmetic_type val) &&noexcept
operator=(arithmetic_type val) &&
noexcept
{
storage_type *const GKO_ACC_RESTRICT r_ptr = ptr_;
storage_type* const GKO_ACC_RESTRICT r_ptr = ptr_;
*r_ptr = static_cast<storage_type>(val / scalar_);
return val;
}

constexpr GKO_ACC_ATTRIBUTES arithmetic_type
operator=(const scaled_reduced_storage &ref) &&
operator=(const scaled_reduced_storage& ref) &&
{
std::move(*this) = static_cast<arithmetic_type>(ref);
return static_cast<arithmetic_type>(*this);
}

constexpr GKO_ACC_ATTRIBUTES arithmetic_type
operator=(scaled_reduced_storage &&ref) &&noexcept
operator=(scaled_reduced_storage&& ref) &&
noexcept
{
std::move(*this) = static_cast<arithmetic_type>(ref);
return static_cast<arithmetic_type>(*this);
}

private:
storage_type *const GKO_ACC_RESTRICT ptr_;
storage_type* const GKO_ACC_RESTRICT ptr_;
const arithmetic_type scalar_;
};

Expand All @@ -422,37 +426,37 @@ class scaled_reduced_storage<ArithmeticType, const StorageType>
using storage_type = const StorageType;

// Allow move construction, so perfect forwarding is possible
scaled_reduced_storage(scaled_reduced_storage &&) = default;
scaled_reduced_storage(scaled_reduced_storage&&) = default;

scaled_reduced_storage() = delete;

~scaled_reduced_storage() = default;

// Forbid copy construction and move assignment
scaled_reduced_storage(const scaled_reduced_storage &) = delete;
scaled_reduced_storage(const scaled_reduced_storage&) = delete;

scaled_reduced_storage &operator=(scaled_reduced_storage &&) = delete;
scaled_reduced_storage& operator=(scaled_reduced_storage&&) = delete;

constexpr explicit GKO_ACC_ATTRIBUTES scaled_reduced_storage(
storage_type *const GKO_ACC_RESTRICT ptr, arithmetic_type scalar)
storage_type* const GKO_ACC_RESTRICT ptr, arithmetic_type scalar)
: ptr_{ptr}, scalar_{scalar}
{}

constexpr GKO_ACC_ATTRIBUTES operator arithmetic_type() const
{
const storage_type *const GKO_ACC_RESTRICT r_ptr = ptr_;
const storage_type* const GKO_ACC_RESTRICT r_ptr = ptr_;
return static_cast<arithmetic_type>(*r_ptr) * scalar_;
}

private:
storage_type *const GKO_ACC_RESTRICT ptr_;
storage_type* const GKO_ACC_RESTRICT ptr_;
const arithmetic_type scalar_;
};


template <typename ArithmeticType, typename StorageType>
constexpr remove_complex_t<ArithmeticType> abs(
const scaled_reduced_storage<ArithmeticType, StorageType> &ref)
const scaled_reduced_storage<ArithmeticType, StorageType>& ref)
{
using std::abs;
return abs(static_cast<ArithmeticType>(ref));
Expand Down
6 changes: 3 additions & 3 deletions accessor/block_col_major.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class block_col_major {
/**
* Type of underlying data storage.
*/
using data_type = value_type *;
using data_type = value_type*;

using const_accessor = block_col_major<const ValueType, Dimensionality>;
using stride_type = std::array<size_type, dimensionality - 1>;
Expand Down Expand Up @@ -142,8 +142,8 @@ class block_col_major {
*/
template <typename... Indices>
constexpr GKO_ACC_ATTRIBUTES
std::enable_if_t<are_all_integral<Indices...>::value, value_type &>
operator()(Indices &&... indices) const
std::enable_if_t<are_all_integral<Indices...>::value, value_type&>
operator()(Indices&&... indices) const
{
return data[helper::blk_col_major::compute_index(
lengths, stride, std::forward<Indices>(indices)...)];
Expand Down
16 changes: 8 additions & 8 deletions accessor/index_span.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,38 +89,38 @@ struct index_span {
*/
GKO_ACC_ATTRIBUTES constexpr bool is_valid() const { return begin < end; }

friend GKO_ACC_ATTRIBUTES constexpr bool operator<(const index_span &first,
const index_span &second)
friend GKO_ACC_ATTRIBUTES constexpr bool operator<(const index_span& first,
const index_span& second)
{
return first.end < second.begin;
}

friend GKO_ACC_ATTRIBUTES constexpr bool operator<=(
const index_span &first, const index_span &second)
const index_span& first, const index_span& second)
{
return first.end <= second.begin;
}

friend GKO_ACC_ATTRIBUTES constexpr bool operator>(const index_span &first,
const index_span &second)
friend GKO_ACC_ATTRIBUTES constexpr bool operator>(const index_span& first,
const index_span& second)
{
return second < first;
}

friend GKO_ACC_ATTRIBUTES constexpr bool operator>=(
const index_span &first, const index_span &second)
const index_span& first, const index_span& second)
{
return second <= first;
}

friend GKO_ACC_ATTRIBUTES constexpr bool operator==(
const index_span &first, const index_span &second)
const index_span& first, const index_span& second)
{
return first.begin == second.begin && first.end == second.end;
}

friend GKO_ACC_ATTRIBUTES constexpr bool operator!=(
const index_span &first, const index_span &second)
const index_span& first, const index_span& second)
{
return !(first == second);
}
Expand Down
Loading

0 comments on commit 1f476bd

Please sign in to comment.