Skip to content

Commit 4d72288

Browse files
committed
🚨 fix clang-tidy warnings for C++20
Signed-off-by: burgholzer <burgholzer@me.com>
1 parent e34f26c commit 4d72288

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

‎examples/device/device.cpp‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
#include <utility>
4242
#include <vector>
4343

44+
// NOLINTBEGIN(*-pro-bounds-avoid-unchecked-container-access,*-throwing-static-initialization)
45+
4446
enum class CXX_QDMI_DEVICE_SESSION_STATUS : uint8_t { ALLOCATED, INITIALIZED };
4547

4648
struct CXX_QDMI_Device_Session_impl_d {
@@ -464,8 +466,8 @@ int CXX_QDMI_device_job_submit(CXX_QDMI_Device_Job job) {
464466
for (size_t i = 0; i < job->num_shots; ++i) {
465467
// generate random bitstring
466468
std::string result(num_qubits, '0');
467-
std::generate(result.begin(), result.end(),
468-
[&]() { return CXX_QDMI_generate_bit() ? '1' : '0'; });
469+
std::ranges::generate(
470+
result, [&]() { return CXX_QDMI_generate_bit() ? '1' : '0'; });
469471
job->results.emplace_back(std::move(result));
470472
}
471473
// Generate random complex numbers and calculate the norm
@@ -567,7 +569,7 @@ int CXX_QDMI_device_job_get_results_hist(CXX_QDMI_Device_Job job,
567569
}
568570
char *data_ptr = static_cast<char *>(data);
569571
for (const auto &[bitstring, count] : hist) {
570-
std::copy(bitstring.begin(), bitstring.end(), data_ptr);
572+
std::ranges::copy(bitstring, data_ptr);
571573
data_ptr += bitstring.length();
572574
*data_ptr++ = ',';
573575
}
@@ -900,3 +902,5 @@ int CXX_QDMI_device_session_query_operation_property(
900902
}
901903
return QDMI_ERROR_NOTSUPPORTED;
902904
} /// [DOXYGEN FUNCTION END]
905+
906+
// NOLINTEND(*-pro-bounds-avoid-unchecked-container-access,*-throwing-static-initialization)

‎examples/driver/qdmi_example_driver.cpp‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -257,12 +257,11 @@ bool Is_path_allowed(const std::filesystem::path &path) {
257257
}
258258

259259
// Check if the resolved path starts with any of the allowlisted directories.
260-
return std::any_of(
261-
allowlist.begin(), allowlist.end(), [&](const auto &allowed_path) {
262-
return std::mismatch(allowed_path.begin(), allowed_path.end(),
263-
resolved_path.begin(), resolved_path.end())
264-
.first == allowed_path.end();
265-
});
260+
return std::ranges::any_of(allowlist, [&](const auto &allowed_path) {
261+
return std::mismatch(allowed_path.begin(), allowed_path.end(),
262+
resolved_path.begin(), resolved_path.end())
263+
.first == allowed_path.end();
264+
});
266265
}
267266
} // namespace
268267

‎test/utils/test_impl.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ void QDMIImplementationTest::SetUp() {
4545
auto test_name =
4646
test_info->test_suite_name() + std::string("_") + test_info->name();
4747
// replace all `/` with `_` in the test name
48-
std::replace(test_name.begin(), test_name.end(), '/', '_');
48+
std::ranges::replace(test_name, '/', '_');
4949

5050
config_file_name = "qdmi_" + test_name + ".conf";
5151
std::ofstream conf_file(config_file_name);

0 commit comments

Comments
 (0)