While enabling clang-tidy support (#63 and #64) this error came up:
../src/object_async/hello_async.cpp:210:5: error: const string& members are dangerous; it is much better to use alternatives, such as pointers or simple constants [google-runtime-member-string-references,-warnings-as-errors]
std::string const& name_;
^
And I found: https://clang.llvm.org/extra/clang-tidy/checks/google-runtime-member-string-references.html
This is interesting/surprising. I've used const std::string & members before and gotten away clean, I think. The motivation here for @GretaCB and I was to ensure we did not need to copy this string when going into the threadpool. The name is owned by the HelloObjectAsync class here and is only temporarily neede by the the AsyncHelloWorker that takes the const reference and keeps it as a member here.
This warning indicates that member references are worst than a pointer, which would achieve the same purpose. So I'm going to look into using a pointer.
While enabling clang-tidy support (#63 and #64) this error came up:
And I found: https://clang.llvm.org/extra/clang-tidy/checks/google-runtime-member-string-references.html
This is interesting/surprising. I've used
const std::string &members before and gotten away clean, I think. The motivation here for @GretaCB and I was to ensure we did not need to copy this string when going into the threadpool. Thenameis owned by theHelloObjectAsyncclass here and is only temporarily neede by the theAsyncHelloWorkerthat takes the const reference and keeps it as a member here.This warning indicates that member references are worst than a pointer, which would achieve the same purpose. So I'm going to look into using a pointer.