[PATCH] D142606: Lazyly initialize uncommon toolchain detector
Markus Böck via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 2 04:32:01 PST 2023
zero9178 added inline comments.
================
Comment at: clang/lib/Driver/ToolChains/LazyDetector.h:26
+
+ mutable std::optional<T> Detector;
+
----------------
serge-sans-paille wrote:
> zero9178 wrote:
> > Any reason this is `mutable`? I don't see it being used a non-const way in a const method
> yeah, `T const *operator->() const` updates the optional by actually creating the value. (`std::optional::empalce` is not const)
Your `T const *operator->() const` method does not do so, `T *operator->()` does, which is non-const and hence can call `emplace` without issues.
So as far as C++ goes it is not required.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D142606/new/
https://reviews.llvm.org/D142606
More information about the cfe-commits
mailing list