Skip to content

Commit 1e3f918

Browse files
committed
Batch clang format files with script.
1 parent 8d500a5 commit 1e3f918

File tree

419 files changed

+4340
-5668
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

419 files changed

+4340
-5668
lines changed

AbstractDataType/queue.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
/**
22
* @brief Contains declaration of a commonly-seen data structure queue implemented in C.
3-
*
3+
*
44
*/
55

66
#ifndef QUEUE_H
77
#define QUEUE_H
88

9+
#include <limits.h>
910
#include <stdbool.h>
1011
#include <stdio.h>
1112
#include <stdlib.h>
12-
#include <limits.h>
1313

1414
#define QUEUE_EMPTY INT_MIN
1515

@@ -24,10 +24,10 @@ typedef struct _queue queue;
2424
// the compiler knows what to do with a pointer (an address)
2525
// so long as it is NOT de-referenced
2626
queue* q_create(int max_size);
27-
void q_destroy(queue *q);
28-
bool q_empty(queue *q);
29-
bool q_full(queue *q);
30-
bool q_endqueue(queue *q, int value);
31-
int q_dequeue(queue *q);
27+
void q_destroy(queue* q);
28+
bool q_empty(queue* q);
29+
bool q_full(queue* q);
30+
bool q_endqueue(queue* q, int value);
31+
int q_dequeue(queue* q);
3232

3333
#endif

Array/array_size.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
#pragma once
22

3-
template<typename T, auto N>
4-
[[nodiscard]] consteval auto array_size(T (&)[N])
5-
{
3+
template <typename T, auto N>
4+
[[nodiscard]]
5+
consteval auto array_size(T (&)[N]) {
66
return N;
77
}
88

9-
template<typename T>
9+
template <typename T>
1010
requires requires { std::declval<T>().size(); }
11-
[[nodiscard]] constexpr auto array_size(T&& t)
12-
{
11+
[[nodiscard]]
12+
constexpr auto array_size(T&& t) {
1313
return t.size();
1414
}

Array/iterable_array.cpp

Lines changed: 33 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -7,110 +7,88 @@
77
#include <utility>
88
#include <vector>
99

10-
template<typename T>
10+
template <typename T>
1111
concept is_iterable = requires (T array_like) {
12-
{
13-
array_like.has_next()
14-
} -> std::convertible_to<bool>;
15-
{
16-
array_like.next()
17-
} -> std::same_as<uint32_t>;
18-
{
19-
array_like.reset()
20-
};
12+
{ array_like.has_next() } -> std::convertible_to<bool>;
13+
{ array_like.next() } -> std::same_as<uint32_t>;
14+
{ array_like.reset() };
2115
};
2216

23-
template<is_iterable T>
24-
constexpr std::size_t count(T array)
25-
{
17+
template <is_iterable T>
18+
constexpr std::size_t count(T array) {
2619
array.reset();
2720
std::size_t count = 0;
28-
while (array.has_next())
29-
{
21+
while (array.has_next()) {
3022
array.next();
3123
count++;
3224
}
3325
return count;
3426
}
3527

36-
template<typename T>
37-
constexpr std::size_t count(T&& array)
38-
{
28+
template <typename T>
29+
constexpr std::size_t count(T&& array) {
3930
return count(array);
4031
}
4132

42-
struct iterable_array
43-
{
44-
inline constexpr iterable_array() noexcept = default;
45-
inline constexpr iterable_array(const iterable_array&) noexcept = default;
46-
inline constexpr iterable_array(const std::size_t s)
47-
: array(s)
48-
{
49-
}
50-
inline constexpr ~iterable_array() noexcept = default;
33+
struct iterable_array {
34+
constexpr inline iterable_array() noexcept = default;
35+
constexpr inline iterable_array(const iterable_array&) noexcept = default;
36+
constexpr inline iterable_array(const std::size_t s)
37+
: array(s) {}
38+
constexpr inline ~iterable_array() noexcept = default;
5139

5240
std::vector<uint32_t> array{};
5341
std::size_t index = 0;
5442

55-
inline constexpr void reset() { index = 0; }
56-
inline constexpr bool has_next() const noexcept { return index < array.size(); }
57-
inline constexpr std::uint32_t next()
58-
{
43+
constexpr inline void reset() { index = 0; }
44+
constexpr inline bool has_next() const noexcept { return index < array.size(); }
45+
constexpr inline std::uint32_t next() {
5946
index++;
6047
return array[index - 1];
6148
}
6249
};
6350

64-
consteval [[nodiscard]] std::size_t __cdecl count_iterable_array()
65-
{
51+
consteval [[nodiscard]] std::size_t __cdecl count_iterable_array() {
6652
static_assert(std::is_constant_evaluated());
6753
return count(iterable_array(10));
6854
}
6955

70-
namespace std
71-
{
56+
namespace std {
7257

73-
template<>
74-
struct tuple_size<iterable_array> : integral_constant<std::size_t, 2>
75-
{
76-
};
58+
template <>
59+
struct tuple_size<iterable_array> : integral_constant<std::size_t, 2> {};
7760

78-
template<>
79-
struct tuple_element<0U, iterable_array>
80-
{
61+
template <>
62+
struct tuple_element<0U, iterable_array> {
8163
using type = vector<uint32_t>;
8264
};
8365

84-
template<>
85-
struct tuple_element<1U, iterable_array>
86-
{
66+
template <>
67+
struct tuple_element<1U, iterable_array> {
8768
using type = size_t;
8869
};
8970

90-
template<size_t I>
71+
template <size_t I>
9172
requires (I < tuple_size<iterable_array>::value)
92-
typename tuple_element<I, iterable_array>::type& get(iterable_array& itrarray)
93-
{
73+
typename tuple_element<I, iterable_array>::type& get(iterable_array& itrarray) {
9474
if constexpr (I == 0)
9575
return itrarray.array;
9676
else /* constexpr */
9777
return itrarray.index;
9878
}
9979

100-
template<size_t I>
80+
template <size_t I>
10181
requires (I < tuple_size<iterable_array>::value)
102-
typename const tuple_element<I, iterable_array>::type& get(const iterable_array& itrarray)
103-
{
82+
typename const tuple_element<I, iterable_array>::type& get(const iterable_array& itrarray) {
10483
if constexpr (I == 0)
10584
return itrarray.array;
10685
else /* constexpr */
10786
return itrarray.index;
10887
}
10988

110-
template<size_t I>
89+
template <size_t I>
11190
requires (I < tuple_size<iterable_array>::value)
112-
typename tuple_element<I, iterable_array>::type&& get(iterable_array&& itrarray)
113-
{
91+
typename tuple_element<I, iterable_array>::type&& get(iterable_array&& itrarray) {
11492
if constexpr (I == 0)
11593
return std::forward<tuple_element<0U, iterable_array>::type>(itrarray.array);
11694
else /* constexpr */
@@ -119,8 +97,7 @@ typename tuple_element<I, iterable_array>::type&& get(iterable_array&& itrarray)
11997

12098
} // namespace std
12199

122-
auto main(void) -> int
123-
{
100+
int main(void) {
124101
static_assert(std::tuple_size<iterable_array>::value == 2);
125102
static_assert(std::tuple_size_v<iterable_array> == 2);
126103
static_assert(std::is_same_v<std::tuple_element<0, iterable_array>::type, std::vector<std::uint32_t>>);

Array/std_array_get_impl.inl

Lines changed: 22 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,29 @@
1-
namespace std _GLIBCXX_VISIBILITY(default)
2-
{
1+
namespace std _GLIBCXX_VISIBILITY(default) {
32
_GLIBCXX_BEGIN_NAMESPACE_CONTAINER
43

5-
template<std::size_t _Int, typename _Tp, std::size_t _Nm>
6-
constexpr _Tp&
7-
get(array<_Tp, _Nm>& __arr) noexcept
8-
{
9-
static_assert(_Int < _Nm, "array index is within bounds");
10-
return _GLIBCXX_STD_C::__array_traits<_Tp, _Nm>::
11-
_S_ref(__arr._M_elems, _Int);
12-
}
4+
template <std::size_t _Int, typename _Tp, std::size_t _Nm>
5+
constexpr _Tp& get(array<_Tp, _Nm>& __arr) noexcept {
6+
static_assert(_Int < _Nm, "array index is within bounds");
7+
return _GLIBCXX_STD_C::__array_traits<_Tp, _Nm>::_S_ref(__arr._M_elems, _Int);
8+
}
139

14-
template<std::size_t _Int, typename _Tp, std::size_t _Nm>
15-
constexpr _Tp&&
16-
get(array<_Tp, _Nm>&& __arr) noexcept
17-
{
18-
static_assert(_Int < _Nm, "array index is within bounds");
19-
return std::move(_GLIBCXX_STD_C::get<_Int>(__arr));
20-
}
10+
template <std::size_t _Int, typename _Tp, std::size_t _Nm>
11+
constexpr _Tp&& get(array<_Tp, _Nm>&& __arr) noexcept {
12+
static_assert(_Int < _Nm, "array index is within bounds");
13+
return std::move(_GLIBCXX_STD_C::get<_Int>(__arr));
14+
}
2115

22-
template<std::size_t _Int, typename _Tp, std::size_t _Nm>
23-
constexpr const _Tp&
24-
get(const array<_Tp, _Nm>& __arr) noexcept
25-
{
26-
static_assert(_Int < _Nm, "array index is within bounds");
27-
return _GLIBCXX_STD_C::__array_traits<_Tp, _Nm>::
28-
_S_ref(__arr._M_elems, _Int);
29-
}
16+
template <std::size_t _Int, typename _Tp, std::size_t _Nm>
17+
constexpr const _Tp& get(const array<_Tp, _Nm>& __arr) noexcept {
18+
static_assert(_Int < _Nm, "array index is within bounds");
19+
return _GLIBCXX_STD_C::__array_traits<_Tp, _Nm>::_S_ref(__arr._M_elems, _Int);
20+
}
3021

31-
template<std::size_t _Int, typename _Tp, std::size_t _Nm>
32-
constexpr const _Tp&&
33-
get(const array<_Tp, _Nm>&& __arr) noexcept
34-
{
35-
static_assert(_Int < _Nm, "array index is within bounds");
36-
return std::move(_GLIBCXX_STD_C::get<_Int>(__arr));
37-
}
22+
template <std::size_t _Int, typename _Tp, std::size_t _Nm>
23+
constexpr const _Tp&& get(const array<_Tp, _Nm>&& __arr) noexcept {
24+
static_assert(_Int < _Nm, "array index is within bounds");
25+
return std::move(_GLIBCXX_STD_C::get<_Int>(__arr));
26+
}
3827

3928
_GLIBCXX_END_NAMESPACE_CONTAINER
40-
} // namespace std
29+
} // namespace std _GLIBCXX_VISIBILITY(default)

BitwiseOperator/bitwise_operator.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,11 @@
88

99
#include <iostream>
1010

11-
void print(const int value)
12-
{
11+
void print(const int value) {
1312
std::cout << value << "\n";
1413
}
1514

16-
int main(void)
17-
{
15+
int main(void) {
1816
unsigned int a = 5;
1917
// Debug -> Windows -> Memory -> Memory1
2018
// OR Ctrl + Alt+ M, 1

Boost/LambdaExample/lambda.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,16 @@
1717
* \date September 2022
1818
*********************************************************************/
1919

20+
#include <algorithm>
2021
#include <boost/lambda/lambda.hpp>
2122
#include <iostream>
2223
#include <iterator>
23-
#include <algorithm>
2424

25-
auto main(void) -> int {
25+
int main(void) {
2626
using namespace boost::lambda;
2727
typedef std::istream_iterator<int> in;
2828

29-
std::for_each(
30-
in(std::cin), in(), std::cout << (_1 * 3) << " "
31-
);
29+
std::for_each(in(std::cin), in(), std::cout << (_1 * 3) << " ");
3230

3331
return EXIT_SUCCESS;
3432
}

Boost/MultiArray/multi_array.cpp

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@
1212
#include <boost/multi_array.hpp>
1313
#include <iostream>
1414

15-
int main()
16-
{
15+
int main() {
1716
// define the shape of the tensor (3D)
18-
const int d1 = 2;
19-
const int d2 = 3;
20-
const int d3 = 4;
17+
const int d1 = 2;
18+
const int d2 = 3;
19+
const int d3 = 4;
2120

2221
// create the tensor
2322
// 3 dimensional array
@@ -27,24 +26,18 @@ int main()
2726
tensor_t tensor(boost::extents[d1][d2][d3]);
2827

2928
// fill the tensor with some values
30-
for (int i = 0; i < d1; ++i)
31-
{
32-
for (int j = 0; j < d2; ++j)
33-
{
34-
for (int k = 0; k < d3; ++k)
35-
{
29+
for (int i = 0; i < d1; ++i) {
30+
for (int j = 0; j < d2; ++j) {
31+
for (int k = 0; k < d3; ++k) {
3632
tensor[i][j][k] = i * j * k;
3733
}
3834
}
3935
}
4036

4137
// print the tensor
42-
for (int i = 0; i < d1; ++i)
43-
{
44-
for (int j = 0; j < d2; ++j)
45-
{
46-
for (int k = 0; k < d3; ++k)
47-
{
38+
for (int i = 0; i < d1; ++i) {
39+
for (int j = 0; j < d2; ++j) {
40+
for (int k = 0; k < d3; ++k) {
4841
std::cout << tensor[i][j][k] << " ";
4942
}
5043
std::cout << "\n";

Boost/StringRef/string_ref.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
* \date December 07, 2022
88
*********************************************************************/
99

10-
#include <iostream>
1110
#include <stdlib.h>
12-
#include <string>
13-
#include <cassert>
14-
#include <boost/utility/string_ref.hpp>
1511

16-
auto main(void) -> int {
12+
#include <boost/utility/string_ref.hpp>
13+
#include <cassert>
14+
#include <iostream>
15+
#include <string>
1716

18-
const char* c_str = { "Days of Future Past" };
17+
int main(void) {
18+
const char* c_str = {"Days of Future Past"};
1919
std::string cpp_str(c_str);
2020

2121
boost::string_ref c_str_ref(c_str);
@@ -27,7 +27,7 @@ auto main(void) -> int {
2727

2828
boost::string_ref first_4_chars(c_str, 4); // "Days"
2929
// note: boost::string_ref also supports substr()
30-
assert(cpp_str_ref.front() == 'D');
30+
assert(cpp_str_ref.front() == 'D');
3131
assert(first_4_chars == cpp_str.substr(0, 4));
3232

3333
auto first_five_chars = [](boost::string_ref str_ref) -> boost::string_ref {

0 commit comments

Comments
 (0)