Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 36 additions & 12 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
Language: Cpp
AccessModifierOffset: -4
AlignAfterOpenBracket: BlockIndent
AlignAfterOpenBracket: true
AlignArrayOfStructures: None
AlignConsecutiveAssignments:
Enabled: false
Expand Down Expand Up @@ -68,11 +68,13 @@ AlignConsecutiveTableGenDefinitionColons:
AlignEscapedNewlines: DontAlign
AlignOperands: DontAlign
AlignTrailingComments:
AlignPPAndNotPP: false
Kind: Never
OverEmptyLines: 0
AllowAllArgumentsOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowBreakBeforeNoexceptSpecifier: Never
AllowBreakBeforeNoexceptSpecifier: Always
AllowBreakBeforeQtProperty: false
AllowShortBlocksOnASingleLine: Never
AllowShortCaseExpressionOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
Expand All @@ -89,7 +91,7 @@ AttributeMacros:
- __capability
BinPackArguments: false
BinPackLongBracedList: true
BinPackParameters: false
BinPackParameters: OnePerLine
BitFieldColonSpacing: Both
BracedInitializerIndentWidth: -1
BraceWrapping:
Expand All @@ -114,9 +116,19 @@ BraceWrapping:
BreakAdjacentStringLiterals: true
BreakAfterAttributes: Leave
BreakAfterJavaFieldAnnotations: false
BreakAfterOpenBracketBracedList: true
BreakAfterOpenBracketFunction: true
BreakAfterOpenBracketIf: true
BreakAfterOpenBracketLoop: true
BreakAfterOpenBracketSwitch: true
BreakAfterReturnType: None
BreakArrays: true
BreakBeforeBinaryOperators: All
BreakBeforeCloseBracketBracedList: true
BreakBeforeCloseBracketFunction: true
BreakBeforeCloseBracketIf: true
BreakBeforeCloseBracketLoop: true
BreakBeforeCloseBracketSwitch: true
BreakBeforeConceptDeclarations: Always
BreakBeforeBraces: Custom
BreakBeforeInlineASMColon: OnlyMultiline
Expand All @@ -133,7 +145,7 @@ CommentPragmas: "^ IWYU pragma:"
CompactNamespaces: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
Cpp11BracedListStyle: FunctionCall
DerivePointerAlignment: false
DisableFormat: false
EmptyLineAfterAccessModifier: Never
Expand Down Expand Up @@ -166,7 +178,7 @@ IncludeIsMainSourceRegex: ""
IndentAccessModifiers: false
IndentCaseBlocks: false
IndentCaseLabels: false
IndentExportBlock: false
IndentExportBlock: true
IndentExternBlock: AfterExternBlock
IndentGotoLabels: true
IndentPPDirectives: None
Expand All @@ -178,10 +190,16 @@ InsertNewlineAtEOF: true
InsertTrailingCommas: Wrapped
IntegerLiteralSeparator:
Binary: 0
BinaryMinDigits: 0
BinaryMinDigitsInsert: 0
BinaryMaxDigitsRemove: 0
Decimal: 0
DecimalMinDigits: 0
DecimalMinDigitsInsert: 0
DecimalMaxDigitsRemove: 0
Hex: 0
HexMinDigitsInsert: 0
HexMaxDigitsRemove: 0
BinaryMinDigits: 0
DecimalMinDigits: 0
HexMinDigits: 0
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
Expand All @@ -191,12 +209,17 @@ KeepEmptyLines:
AtStartOfFile: false
KeepFormFeed: false
LambdaBodyIndentation: Signature
LineEnding: DeriveLF
LineEnding: LF
MacroBlockBegin: ""
MacroBlockEnd: ""
MainIncludeChar: Quote
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
NumericLiteralCase:
ExponentLetter: Upper
HexDigit: Upper
Prefix: Upper
Suffix: Upper
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 2
ObjCBreakBeforeNestedBlockParam: true
Expand All @@ -223,7 +246,7 @@ ReferenceAlignment: Pointer
ReflowComments: Always
RemoveBracesLLVM: false
RemoveEmptyLinesInUnwrappedLines: false
RemoveParentheses: MultipleParentheses
RemoveParentheses: ReturnStatement
RemoveSemicolon: true
RequiresClausePosition: OwnLine
RequiresExpressionIndentation: OuterScope
Expand All @@ -233,6 +256,7 @@ SkipMacroDefinitionBody: false
SortIncludes:
Enabled: true
IgnoreCase: false
IgnoreExtension: false
SortJavaStaticImport: Before
SortUsingDeclarations: LexicographicNumeric
SpaceAfterCStyleCast: false
Expand All @@ -255,13 +279,13 @@ SpaceBeforeParensOptions:
AfterIfMacros: true
AfterNot: true
AfterOverloadedOperator: false
AfterPlacementOperator: false
AfterPlacementOperator: true
AfterRequiresInClause: true
AfterRequiresInExpression: true
BeforeNonEmptyParentheses: false
SpaceBeforeRangeBasedForLoopColon: true
SpaceBeforeSquareBrackets: false
SpaceInEmptyBlock: false
SpaceInEmptyBraces: Never
SpacesBeforeTrailingComments: 1
SpacesInAngles: Never
SpacesInContainerLiterals: true
Expand Down Expand Up @@ -293,5 +317,5 @@ WhitespaceSensitiveMacros:
- PP_STRINGIZE
- STRINGIZE
WrapNamespaceBodyWithEmptyLines: Always
...
---

4 changes: 0 additions & 4 deletions benchmark/encode_and_decode_strings_benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ TEST_CASE(
std::ostream output_stream{&buffer};

static constexpr std::array const tokens{
// clang-format off
"abcd ~~~~efghabcd ~~~~efgh"
"abcd ~~~~efghabcd ~~~~efgh"
"abcd ~~~~efghabcd ~~~~efgh"
Expand All @@ -46,7 +45,6 @@ TEST_CASE(
"abcd ~~~~efghabcd ~~~~efgh"
"abcd ~~~~efghabcd ~~~~efgh"
"abcd ~~~~efghabcd ~~~~efgh"sv,
// clang-format on
};
static_assert(tokens.size() == 2UZ);
static_assert(tokens[0].size() == 256UZ);
Expand Down Expand Up @@ -80,7 +78,6 @@ TEST_CASE(
using Traits = std::string_view::traits_type;

static constexpr std::string_view const encoded{
// clang-format off
"abcd~ ~ ~ ~ ~~~~~~~~efghabcd~ ~ ~ ~ ~~~~~~~~efghabcd~ ~ ~ ~ ~~~~"
"~~~~efghabcd~ ~ ~ ~ ~~~~~~~~efghabcd~ ~ ~ ~ ~~~~~~~~efghabcd~ ~ "
"~ ~ ~~~~~~~~efghabcd~ ~ ~ ~ ~~~~~~~~efghabcd~ ~ ~ ~ ~~~~~~~~efgh"
Expand All @@ -94,7 +91,6 @@ TEST_CASE(
"~~~~~efghabcd~ ~ ~ ~ ~~~~~~~~efghabcd~ ~ ~ ~ ~~~~~~~~efghabcd~ ~"
" ~ ~ ~~~~~~~~efghabcd~ ~ ~ ~ ~~~~~~~~efghabcd~ ~ ~ ~ ~~~~~~~~efg"
"h"
// clang-format on
};
static_assert(encoded.size() == 769UZ);

Expand Down
2 changes: 0 additions & 2 deletions benchmark/valid_sudoku_benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ TEST_CASE("Valid Sudoku benchmarking", "[benchmark][valid_sudoku]")
using namespace forfun::valid_sudoku;

SudokuBoard<std::uint8_t> board{{
// clang-format off
{5, 3, 0, 0, 7, 0, 0, 0, 0},
{6, 0, 0, 1, 9, 5, 0, 0, 0},
{0, 9, 8, 0, 0, 0, 0, 6, 0},
Expand All @@ -29,7 +28,6 @@ TEST_CASE("Valid Sudoku benchmarking", "[benchmark][valid_sudoku]")
{0, 6, 0, 0, 0, 0, 2, 8, 0},
{0, 0, 0, 4, 1, 9, 0, 0, 5},
{0, 0, 0, 0, 8, 0, 0, 7, 9},
// clang-format on
}};

ankerl::nanobench::Bench()
Expand Down
7 changes: 1 addition & 6 deletions fuzz/evaluate_reverse_polish_notation_fuzz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,7 @@ auto ArbitraryOperand() -> ::fuzztest::Domain<std::int64_t>
auto ArbitraryOperandAndOperation() -> ::fuzztest::Domain<OperandOperationPair>
{
return ::fuzztest::Map(
[](
// clang-format off
int operand,
char operation
// clang-format on
) -> OperandOperationPair {
[](int operand, char operation) -> OperandOperationPair {
OperandOperationPair p{std::make_pair(operand, operation)};
return p;
},
Expand Down
8 changes: 4 additions & 4 deletions include/forfun/container/forward_list.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ class forward_list final {

constexpr auto clear() noexcept -> void
{
// clang-format off
for (forfun::container::forward_list_node<T> const* node{head_};
node != nullptr;)
// clang-format on
for (
forfun::container::forward_list_node<T> const* node{head_};
node != nullptr;
)
{
forfun::container::forward_list_node<T> const* const next{
node->next_
Expand Down
9 changes: 1 addition & 8 deletions include/forfun/contains_duplicate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,7 @@ contains_duplicate(Iter iter, Sentinel const last, BinaryPredicate eq) noexcept(
/// @note The strategy assumes that @p first and @p last point to a non-empty
/// span of elements, otherwise the behavior of the strategy is undefined.
template <typename Iter, typename Sentinel>
// clang-format off
requires std::forward_iterator<Iter>
and std::sentinel_for<Sentinel, Iter>
// clang-format on
requires std::forward_iterator<Iter> and std::sentinel_for<Sentinel, Iter>
[[nodiscard]] constexpr auto
contains_duplicate(Iter const first, Sentinel const last) noexcept(
noexcept(std::declval<std::equal_to<>>()(
Expand Down Expand Up @@ -118,10 +115,8 @@ contains_duplicate(Iter iter, Sentinel const last, BinaryPredicate eq) noexcept(
/// @note The strategy assumes that @p first and @p last point to a non-empty
/// span of elements, otherwise the behavior of the strategy is undefined.
template <typename Iter, typename Sentinel>
// clang-format off
requires std::random_access_iterator<Iter>
and std::sentinel_for<Sentinel, Iter>
// clang-format on
[[nodiscard]] constexpr auto
contains_duplicate(Iter const first, Sentinel const last) noexcept(
noexcept(std::declval<std::equal_to<>>()(
Expand Down Expand Up @@ -163,10 +158,8 @@ contains_duplicate(Iter const first, Sentinel const last, BinaryPredicate eq)
}

template <typename Iter, typename Sentinel>
// clang-format off
requires std::random_access_iterator<Iter>
and std::sentinel_for<Sentinel, Iter>
// clang-format on
[[nodiscard]] constexpr auto
contains_duplicate(Iter const first, Sentinel const last) noexcept(
noexcept(std::declval<std::equal_to<>>()(
Expand Down
8 changes: 4 additions & 4 deletions include/forfun/longest_consecutive_sequence.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,12 @@ template <std::input_iterator Iter, std::sentinel_for<Iter> Sentinel>
std::size_t top_streak{1};
std::size_t streak{1};

// clang-format off
for (auto iter_a{lookup_set.cbegin()},
for (
auto iter_a{lookup_set.cbegin()},
iter_b{std::next(lookup_set.cbegin())};
iter_b != lookup_set.cend();
++iter_a, ++iter_b)
// clang-format on
++iter_a, ++iter_b
)
{
if (ValueType{(*iter_a) + 1} == *iter_b)
{
Expand Down
8 changes: 4 additions & 4 deletions include/forfun/sorting/insertion_sort.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ constexpr auto insertion_sort(Iter const first, Sentinel const last) noexcept
{
for (Iter it_i{std::next(first)}; it_i != last; ++it_i)
{
// clang-format off
for (Iter it_j{it_i};
it_j != first && (*it_j < *std::prev(it_j)); --it_j)
// clang-format on
for (
Iter it_j{it_i}; it_j != first && (*it_j < *std::prev(it_j));
--it_j
)
{
std::iter_swap(it_j, std::prev(it_j));
}
Expand Down
20 changes: 12 additions & 8 deletions include/forfun/three_sum.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,18 @@ template <std::forward_iterator IterA, std::bidirectional_iterator IterB>
result.emplace_back(std::array{*iter, val_j, val_k});
++iter_j;
--iter_k;
while ((std::distance(iter_j, iter_k) > DiffType{})
&& (std::equal_to{}(val_j, *iter_j)))
while (
(std::distance(iter_j, iter_k) > DiffType{})
&& std::equal_to{}(val_j, *iter_j)
)
{
++iter_j;
}

while ((std::distance(iter_j, iter_k) > DiffType{})
&& (std::equal_to{}(val_k, *iter_k)))
while (
(std::distance(iter_j, iter_k) > DiffType{})
&& std::equal_to{}(val_k, *iter_k)
)
{
--iter_k;
}
Expand Down Expand Up @@ -166,11 +170,11 @@ template <std::forward_iterator Iter, std::sized_sentinel_for<Iter> Sentinel>

// We do not utilize std::prev because it does not work with
// std::forward_iterator.
// clang-format off
for (auto iter_a{first};
for (
auto iter_a{first};
iter_a != std::next(first, std::distance(first, last) - 1);
++iter_a)
// clang-format on
++iter_a
)
{
if (std::greater{}(*iter_a, ValueType{}))
{
Expand Down
5 changes: 1 addition & 4 deletions src/forfun/set_matrix_zeroes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,7 @@ auto set_zeroes(std::vector<std::vector<int>>& matrix) noexcept -> void
for (auto row{matrix.begin()}; row != matrix.end(); ++row)
{
DiffC col_offset{1};
// clang-format off
for (auto col{row->begin() + col_offset}; col != row->end();
++col)
// clang-format on
for (auto col{row->begin() + col_offset}; col != row->end(); ++col)
{
if (*(first_element_iter + col_offset) == 0)
{
Expand Down
2 changes: 1 addition & 1 deletion src/forfun/valid_parentheses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace ascii_optimized {
for (ConstIter iter{view.cbegin()}; iter != view.cend(); ++iter)
{
if (char8_t const chr{*iter};
(chr & char8_t{0b00000011}) == char8_t{0b00000001})
(chr & char8_t{0B00000011}) == char8_t{0B00000001})
{
if (expected.empty() || (expected.back() != chr))
{
Expand Down
5 changes: 1 addition & 4 deletions test/array_concatenation_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,7 @@ TEMPLATE_TEST_CASE_SIG(
(auto concatenate, concatenate),
(forfun::array_concatenation::functional::concatenate<int, 256>),
(forfun::array_concatenation::iterator_based::concatenate<int, 256>),
// clang-format off
(forfun::array_concatenation::iterator_based_double::
concatenate<int, 256>),
// clang-format on
(forfun::array_concatenation::iterator_based_double::concatenate<int, 256>),
(forfun::array_concatenation::iterator_unfolded::concatenate<int, 256>),
(forfun::array_concatenation::nested_loops::concatenate<int, 256>),
(forfun::array_concatenation::semi_unfolded::concatenate<int, 256>)
Expand Down
Loading
Loading