prefer passing by reference over value

This commit is contained in:
Danny Robson 2018-07-24 15:46:28 +10:00
parent 946397e325
commit 799768641f
3 changed files with 3 additions and 4 deletions

View File

@ -32,8 +32,7 @@ namespace debug {
public:
backtrace (void);
const decltype(m_frames)& frames(void) const
{ return m_frames; }
const auto& frames(void) const { return m_frames; }
};
std::ostream&

View File

@ -72,7 +72,7 @@ addr2line (const void *addr)
///////////////////////////////////////////////////////////////////////////////
std::ostream&
debug::operator <<(std::ostream &os, const debug::backtrace &rhs) {
const auto frames = rhs.frames ();
auto const &frames = rhs.frames ();
// We don't use the array form of unique_ptr as clang fails on ambigious constructors
typedef std::unique_ptr<char *, decltype(&std::free)> str_t;

View File

@ -22,7 +22,7 @@ main (int, char**)
char c_char[] = { '\0', 'b', 'c' };
bool success = true;
for (auto [i, v, a, c]: util::izip (v_int, a_float, c_char)) {
for (auto const &[i, v, a, c]: util::izip (v_int, a_float, c_char)) {
success = success &&
v_int[i] == v &&
util::equal (a_float[i], a) &&