Skip to content

Commit 702bb45

Browse files
Dev (#12)
Document exception safety. Convert qa tools to python.
1 parent b6be18e commit 702bb45

File tree

8 files changed

+186
-115
lines changed

8 files changed

+186
-115
lines changed

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@
3030
"seccomp=unconfined"
3131
],
3232
"remoteUser": "vscode",
33-
"postStartCommand": "./tools/generate-compilation-database.sh $PWD build-code-quality Debug tests"
33+
"postStartCommand": "./tools/qa compilationdb --build-path=build-code-quality"
3434
}

.github/workflows/test.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,12 @@ jobs:
6969

7070
- name: Code Quality
7171
run: |
72-
./tools/code-quality.sh ${{ github.event.repository.default_branch }} ${{ github.event_name }} ${{github.workspace}} \
73-
${{github.workspace}}/build-code-quality ${{ matrix.config.build_type }} tests
72+
./tools/qa quality --src=${{github.workspace}}/include \
73+
--default-branch=${{ github.event.repository.default_branch }} \
74+
--event=${{ github.event_name }} \
75+
--workspace=${{github.workspace}} \
76+
--build-path=${{github.workspace}}/build-code-quality \
77+
--build-type=${{ matrix.config.build_type }}
7478
if: matrix.config.code_quality == true
7579

7680
- name: Create Build Environment

.vscode/tasks.json

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,31 +45,29 @@
4545
{
4646
"label": "Generate Compilation Database",
4747
"type": "shell",
48-
"command": "./tools/generate-compilation-database.sh",
48+
"command": "./tools/qa",
4949
"args": [
50-
"${workspaceFolder}",
51-
"${workspaceFolder}/build-code-quality",
52-
"Debug",
53-
"tests"
50+
"compilationdb",
51+
"--build-path=${workspaceFolder}/build-code-quality"
5452
],
5553
"problemMatcher": []
56-
},
54+
},
5755
{
5856
"label": "Run clang-tidy on current file",
5957
"type": "shell",
6058
"command": "clang-tidy",
6159
"args": [
62-
"${file}",
63-
"-p=${workspaceFolder}/build-code-quality"
60+
"${file}",
61+
"-p=${workspaceFolder}/build-code-quality"
6462
],
6563
"dependsOn": "Generate Compilation Database",
6664
"problemMatcher": []
67-
},
68-
{
65+
},
66+
{
6967
"label": "Generate Documentation",
7068
"type": "shell",
7169
"command": "doxygen",
7270
"problemMatcher": []
73-
}
71+
}
7472
]
7573
}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ for (auto it = zip.begin(); it != zip.end(); it++) {}
118118
* Consider checked access that returns an optional reference
119119
* Run clang-tidy on file save
120120
* Cancel running jobs on new commit
121+
* Investigate possible documentation issue: [cp: no such file or directory](https://github.com/andreiavrammsd/cpp-zip/actions/runs/10673792787/job/29583324820)
121122
* Test
122123
* Analyze if LCOV_EXCL_LINE is needed
123124
* Finish tests

include/msd/zip.hpp

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -50,43 +50,37 @@ class zip_iterator {
5050
*
5151
* @param iterators The iterators to be zipped together.
5252
*/
53-
explicit zip_iterator(Iterators... iterators) noexcept : iterators_{iterators...} {}
53+
explicit zip_iterator(Iterators... iterators) : iterators_{iterators...} {}
5454

5555
/**
5656
* @brief Dereferences the `zip_iterator` to obtain a tuple of references from each iterator.
5757
*
5858
* @return A tuple containing the values pointed to by each iterator.
5959
*/
60-
value_type operator*() const noexcept { return dereference(std::index_sequence_for<Iterators...>{}); }
60+
value_type operator*() const { return dereference(std::index_sequence_for<Iterators...>{}); }
6161

6262
/**
6363
* @brief Checks if two `zip_iterator` instances are equal.
6464
*
6565
* @param other The other `zip_iterator` to compare with.
6666
* @return `true` if the iterators are equal, `false` otherwise.
6767
*/
68-
bool operator==(const zip_iterator& other) const noexcept
69-
{
70-
return equal(std::index_sequence_for<Iterators...>{}, other);
71-
}
68+
bool operator==(const zip_iterator& other) const { return equal(std::index_sequence_for<Iterators...>{}, other); }
7269

7370
/**
7471
* @brief Checks if two `zip_iterator` instances are not equal.
7572
*
7673
* @param other The other `zip_iterator` to compare with.
7774
* @return `true` if the iterators are not equal, `false` otherwise.
7875
*/
79-
bool operator!=(const zip_iterator& other) const noexcept
80-
{
81-
return !equal(std::index_sequence_for<Iterators...>{}, other);
82-
}
76+
bool operator!=(const zip_iterator& other) const { return !equal(std::index_sequence_for<Iterators...>{}, other); }
8377

8478
/**
8579
* @brief Advances the `zip_iterator` by one position.
8680
*
8781
* @return A reference to the updated `zip_iterator`.
8882
*/
89-
zip_iterator& operator++() noexcept
83+
zip_iterator& operator++()
9084
{
9185
advance(std::index_sequence_for<Iterators...>{}, 1);
9286
return *this;
@@ -98,7 +92,7 @@ class zip_iterator {
9892
* @param offset The number of positions to advance.
9993
* @return A new `zip_iterator` advanced by the specified offset.
10094
*/
101-
zip_iterator operator+(const std::size_t offset) const noexcept
95+
zip_iterator operator+(const std::size_t offset) const
10296
{
10397
auto iterator = *this;
10498
iterator.advance(std::index_sequence_for<Iterators...>{}, offset);
@@ -111,7 +105,7 @@ class zip_iterator {
111105
* @param other The `zip_iterator` to measure the distance to.
112106
* @return A new `zip_iterator` advanced by the distance to the specified iterator.
113107
*/
114-
zip_iterator operator+(const zip_iterator& other) const noexcept
108+
zip_iterator operator+(const zip_iterator& other) const
115109
{
116110
auto iterator = *this;
117111
const auto distance = std::distance(iterator, other);
@@ -124,7 +118,7 @@ class zip_iterator {
124118
*
125119
* @return A reference to the updated `zip_iterator`.
126120
*/
127-
zip_iterator& operator--() noexcept
121+
zip_iterator& operator--()
128122
{
129123
advance(std::index_sequence_for<Iterators...>{}, -1);
130124
return *this;
@@ -136,7 +130,7 @@ class zip_iterator {
136130
* @param offset The number of positions to move back.
137131
* @return A new `zip_iterator` moved back by the specified offset.
138132
*/
139-
zip_iterator operator-(const int offset) const noexcept
133+
zip_iterator operator-(const int offset) const
140134
{
141135
auto iterator = *this;
142136
iterator.advance(std::index_sequence_for<Iterators...>{}, -offset);
@@ -149,7 +143,7 @@ class zip_iterator {
149143
* @param other The `zip_iterator` to measure the distance from.
150144
* @return A new `zip_iterator` moved back by the distance to the specified iterator.
151145
*/
152-
zip_iterator operator-(const zip_iterator& other) const noexcept
146+
zip_iterator operator-(const zip_iterator& other) const
153147
{
154148
auto iterator = *this;
155149
const auto distance = std::distance(other, iterator);
@@ -166,7 +160,7 @@ class zip_iterator {
166160
* @return A tuple containing the values pointed to by each iterator.
167161
*/
168162
template <std::size_t... I>
169-
value_type dereference(std::index_sequence<I...>) const noexcept
163+
value_type dereference(std::index_sequence<I...>) const
170164
{
171165
return std::tie(*std::get<I>(iterators_)...);
172166
}
@@ -180,7 +174,7 @@ class zip_iterator {
180174
* @return `true` if all iterators are equal, `false` otherwise.
181175
*/
182176
template <std::size_t... I>
183-
bool equal(std::index_sequence<I...>, const zip_iterator& other) const noexcept
177+
bool equal(std::index_sequence<I...>, const zip_iterator& other) const
184178
{
185179
return ((std::get<I>(iterators_) == std::get<I>(other.iterators_)) || ...);
186180
}
@@ -193,7 +187,7 @@ class zip_iterator {
193187
* @param offset The number of positions to advance.
194188
*/
195189
template <std::size_t... I>
196-
void advance(std::index_sequence<I...>, const int offset) noexcept
190+
void advance(std::index_sequence<I...>, const int offset)
197191
{
198192
((std::advance(std::get<I>(iterators_), offset)), ...);
199193
}
@@ -208,6 +202,8 @@ class zip_iterator {
208202
* @brief A view over multiple containers simultaneously.
209203
* It allows iterating through multiple containers at once, stopping at the shortest container.
210204
*
205+
* @note The zip never throws explicitly any exception. It all depends on what the given containers throw.
206+
*
211207
* @tparam Containers The types of the containers to be zipped.
212208
* Each container must support standard iteration
213209
* (must have `begin()`, `end()`, `cbegin()`, and `cend()` methods).
@@ -245,7 +241,7 @@ class zip {
245241
* @param containers The containers to be zipped together.
246242
* @pre At least two containers must be provided.
247243
*/
248-
explicit zip(Containers&... containers) noexcept : containers_{containers...} {}
244+
explicit zip(Containers&... containers) : containers_{containers...} {}
249245

250246
/**
251247
* @brief Returns an iterator pointing to the beginning of the zipped containers.
@@ -287,7 +283,7 @@ class zip {
287283
*
288284
* @return `true` if the zipped sequence is empty, `false` otherwise.
289285
*/
290-
[[nodiscard]] bool empty() const noexcept { return begin() == end(); }
286+
[[nodiscard]] bool empty() const { return begin() == end(); }
291287

292288
/**
293289
* @brief Allows the `zip` object to be used in a boolean context, indicating whether the zipped sequence is
@@ -368,7 +364,7 @@ class zip {
368364
* @return An iterator to the beginning of the zipped sequence.
369365
*/
370366
template <typename Iterator, std::size_t... I>
371-
Iterator begin_impl(std::index_sequence<I...>) const noexcept
367+
Iterator begin_impl(std::index_sequence<I...>) const
372368
{
373369
return Iterator{std::get<I>(containers_).begin()...};
374370
}
@@ -382,7 +378,7 @@ class zip {
382378
* @return An iterator to the end of the zipped sequence.
383379
*/
384380
template <typename Iterator, std::size_t... I>
385-
Iterator end_impl(std::index_sequence<I...>) const noexcept
381+
Iterator end_impl(std::index_sequence<I...>) const
386382
{
387383
return std::next(Iterator{std::get<I>(containers_).begin()...}, size());
388384
}

tools/code-quality.sh

Lines changed: 0 additions & 55 deletions
This file was deleted.

tools/generate-compilation-database.sh

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)