[PATCH] D142606: Lazyly initialize uncommon toolchain detector

serge via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Feb 5 02:05:41 PST 2023


serge-sans-paille added inline comments.


================
Comment at: clang/lib/Driver/ToolChains/LazyDetector.h:26
+
+  mutable std::optional<T> Detector;
+
----------------
zero9178 wrote:
> 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. 
gotcha :-)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142606/new/

https://reviews.llvm.org/D142606



More information about the cfe-commits mailing list