Skip to content
Merged

Dev #12

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
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@
"seccomp=unconfined"
],
"remoteUser": "vscode",
"postStartCommand": "./tools/generate-compilation-database.sh $PWD build-code-quality Debug tests"
"postStartCommand": "./tools/qa compilationdb --build-path=build-code-quality"
}
8 changes: 6 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,12 @@ jobs:

- name: Code Quality
run: |
./tools/code-quality.sh ${{ github.event.repository.default_branch }} ${{ github.event_name }} ${{github.workspace}} \
${{github.workspace}}/build-code-quality ${{ matrix.config.build_type }} tests
./tools/qa quality --src=${{github.workspace}}/include \
--default-branch=${{ github.event.repository.default_branch }} \
--event=${{ github.event_name }} \
--workspace=${{github.workspace}} \
--build-path=${{github.workspace}}/build-code-quality \
--build-type=${{ matrix.config.build_type }}
if: matrix.config.code_quality == true

- name: Create Build Environment
Expand Down
20 changes: 9 additions & 11 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,31 +45,29 @@
{
"label": "Generate Compilation Database",
"type": "shell",
"command": "./tools/generate-compilation-database.sh",
"command": "./tools/qa",
"args": [
"${workspaceFolder}",
"${workspaceFolder}/build-code-quality",
"Debug",
"tests"
"compilationdb",
"--build-path=${workspaceFolder}/build-code-quality"
],
"problemMatcher": []
},
},
{
"label": "Run clang-tidy on current file",
"type": "shell",
"command": "clang-tidy",
"args": [
"${file}",
"-p=${workspaceFolder}/build-code-quality"
"${file}",
"-p=${workspaceFolder}/build-code-quality"
],
"dependsOn": "Generate Compilation Database",
"problemMatcher": []
},
{
},
{
"label": "Generate Documentation",
"type": "shell",
"command": "doxygen",
"problemMatcher": []
}
}
]
}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ for (auto it = zip.begin(); it != zip.end(); it++) {}
* Consider checked access that returns an optional reference
* Run clang-tidy on file save
* Cancel running jobs on new commit
* Investigate possible documentation issue: [cp: no such file or directory](https://github.com/andreiavrammsd/cpp-zip/actions/runs/10673792787/job/29583324820)
* Test
* Analyze if LCOV_EXCL_LINE is needed
* Finish tests
Expand Down
42 changes: 19 additions & 23 deletions include/msd/zip.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,43 +50,37 @@ class zip_iterator {
*
* @param iterators The iterators to be zipped together.
*/
explicit zip_iterator(Iterators... iterators) noexcept : iterators_{iterators...} {}
explicit zip_iterator(Iterators... iterators) : iterators_{iterators...} {}

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

/**
* @brief Checks if two `zip_iterator` instances are equal.
*
* @param other The other `zip_iterator` to compare with.
* @return `true` if the iterators are equal, `false` otherwise.
*/
bool operator==(const zip_iterator& other) const noexcept
{
return equal(std::index_sequence_for<Iterators...>{}, other);
}
bool operator==(const zip_iterator& other) const { return equal(std::index_sequence_for<Iterators...>{}, other); }

/**
* @brief Checks if two `zip_iterator` instances are not equal.
*
* @param other The other `zip_iterator` to compare with.
* @return `true` if the iterators are not equal, `false` otherwise.
*/
bool operator!=(const zip_iterator& other) const noexcept
{
return !equal(std::index_sequence_for<Iterators...>{}, other);
}
bool operator!=(const zip_iterator& other) const { return !equal(std::index_sequence_for<Iterators...>{}, other); }

/**
* @brief Advances the `zip_iterator` by one position.
*
* @return A reference to the updated `zip_iterator`.
*/
zip_iterator& operator++() noexcept
zip_iterator& operator++()
{
advance(std::index_sequence_for<Iterators...>{}, 1);
return *this;
Expand All @@ -98,7 +92,7 @@ class zip_iterator {
* @param offset The number of positions to advance.
* @return A new `zip_iterator` advanced by the specified offset.
*/
zip_iterator operator+(const std::size_t offset) const noexcept
zip_iterator operator+(const std::size_t offset) const
{
auto iterator = *this;
iterator.advance(std::index_sequence_for<Iterators...>{}, offset);
Expand All @@ -111,7 +105,7 @@ class zip_iterator {
* @param other The `zip_iterator` to measure the distance to.
* @return A new `zip_iterator` advanced by the distance to the specified iterator.
*/
zip_iterator operator+(const zip_iterator& other) const noexcept
zip_iterator operator+(const zip_iterator& other) const
{
auto iterator = *this;
const auto distance = std::distance(iterator, other);
Expand All @@ -124,7 +118,7 @@ class zip_iterator {
*
* @return A reference to the updated `zip_iterator`.
*/
zip_iterator& operator--() noexcept
zip_iterator& operator--()
{
advance(std::index_sequence_for<Iterators...>{}, -1);
return *this;
Expand All @@ -136,7 +130,7 @@ class zip_iterator {
* @param offset The number of positions to move back.
* @return A new `zip_iterator` moved back by the specified offset.
*/
zip_iterator operator-(const int offset) const noexcept
zip_iterator operator-(const int offset) const
{
auto iterator = *this;
iterator.advance(std::index_sequence_for<Iterators...>{}, -offset);
Expand All @@ -149,7 +143,7 @@ class zip_iterator {
* @param other The `zip_iterator` to measure the distance from.
* @return A new `zip_iterator` moved back by the distance to the specified iterator.
*/
zip_iterator operator-(const zip_iterator& other) const noexcept
zip_iterator operator-(const zip_iterator& other) const
{
auto iterator = *this;
const auto distance = std::distance(other, iterator);
Expand All @@ -166,7 +160,7 @@ class zip_iterator {
* @return A tuple containing the values pointed to by each iterator.
*/
template <std::size_t... I>
value_type dereference(std::index_sequence<I...>) const noexcept
value_type dereference(std::index_sequence<I...>) const
{
return std::tie(*std::get<I>(iterators_)...);
}
Expand All @@ -180,7 +174,7 @@ class zip_iterator {
* @return `true` if all iterators are equal, `false` otherwise.
*/
template <std::size_t... I>
bool equal(std::index_sequence<I...>, const zip_iterator& other) const noexcept
bool equal(std::index_sequence<I...>, const zip_iterator& other) const
{
return ((std::get<I>(iterators_) == std::get<I>(other.iterators_)) || ...);
}
Expand All @@ -193,7 +187,7 @@ class zip_iterator {
* @param offset The number of positions to advance.
*/
template <std::size_t... I>
void advance(std::index_sequence<I...>, const int offset) noexcept
void advance(std::index_sequence<I...>, const int offset)
{
((std::advance(std::get<I>(iterators_), offset)), ...);
}
Expand All @@ -208,6 +202,8 @@ class zip_iterator {
* @brief A view over multiple containers simultaneously.
* It allows iterating through multiple containers at once, stopping at the shortest container.
*
* @note The zip never throws explicitly any exception. It all depends on what the given containers throw.
*
* @tparam Containers The types of the containers to be zipped.
* Each container must support standard iteration
* (must have `begin()`, `end()`, `cbegin()`, and `cend()` methods).
Expand Down Expand Up @@ -245,7 +241,7 @@ class zip {
* @param containers The containers to be zipped together.
* @pre At least two containers must be provided.
*/
explicit zip(Containers&... containers) noexcept : containers_{containers...} {}
explicit zip(Containers&... containers) : containers_{containers...} {}

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

/**
* @brief Allows the `zip` object to be used in a boolean context, indicating whether the zipped sequence is
Expand Down Expand Up @@ -368,7 +364,7 @@ class zip {
* @return An iterator to the beginning of the zipped sequence.
*/
template <typename Iterator, std::size_t... I>
Iterator begin_impl(std::index_sequence<I...>) const noexcept
Iterator begin_impl(std::index_sequence<I...>) const
{
return Iterator{std::get<I>(containers_).begin()...};
}
Expand All @@ -382,7 +378,7 @@ class zip {
* @return An iterator to the end of the zipped sequence.
*/
template <typename Iterator, std::size_t... I>
Iterator end_impl(std::index_sequence<I...>) const noexcept
Iterator end_impl(std::index_sequence<I...>) const
{
return std::next(Iterator{std::get<I>(containers_).begin()...}, size());
}
Expand Down
55 changes: 0 additions & 55 deletions tools/code-quality.sh

This file was deleted.

23 changes: 0 additions & 23 deletions tools/generate-compilation-database.sh

This file was deleted.

Loading
Loading