dwavesystems / dwavesystems/dwave-optimization

Style: Use qualified auto in C++ code

Open
#565 0 comments 0 reactions 0 assignees View on GitHub
question
Dominant language
C++
Stars
31
Forks
36
Avg merge
16h 55m
Merged PRs (30d)
8

Description

We obviously use pointers types a lot in the C++ code. For example we do
```c++
auto x_ptr = graph.emplace_node();
```

IMO we should be using qualified `auto` in these places
```c++
auto* x_ptr = graph.emplace_node();
```
for readability.

Obviously there is a semantic difference if later we need to do say `decltype(auto)` but in most places we never inspect the `auto` and the latter conveys more meaning.

See
- [LLVM Coding Standards](https://llvm.org/docs/CodingStandards.html?utm_source=chatgpt.com#beware-unnecessary-copies-with-auto): "Use auto & for values and auto * for pointers unless you need to make a copy."
- [clang-tidy](https://clang.llvm.org/extra/clang-tidy/checks/readability/qualified-auto.html?utm_source=chatgpt.com)'s readability-qualified-auto

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.