diff options
| author | Nat Goodspeed <nat@lindenlab.com> | 2019-12-11 15:41:01 -0500 | 
|---|---|---|
| committer | Nat Goodspeed <nat@lindenlab.com> | 2020-03-25 19:24:25 -0400 | 
| commit | 557a74fbddac609ce238a7bbafc3138b95956575 (patch) | |
| tree | 516f881df989475cb6d0f97df972971cf8a2143f | |
| parent | e1e9247a310f2b141d25b0c07e224a3236b54b5d (diff) | |
DRTVWR-476: Adapt LLInstanceTracker::snapshot for VS limitations.
| -rw-r--r-- | indra/llcommon/llinstancetracker.h | 38 | 
1 files changed, 36 insertions, 2 deletions
| diff --git a/indra/llcommon/llinstancetracker.h b/indra/llcommon/llinstancetracker.h index 196bc5c0dd..402333cca7 100644 --- a/indra/llcommon/llinstancetracker.h +++ b/indra/llcommon/llinstancetracker.h @@ -143,7 +143,24 @@ public:                              strong_iterator(mData.end(), strengthen));          } -        LockStatic mLock;           // lock static data during construction +        // lock static data during construction +#if ! LL_WINDOWS +        LockStatic mLock; +#else  // LL_WINDOWS +        // We want to be able to use (e.g.) our instance_snapshot subclass as: +        // for (auto& inst : T::instance_snapshot()) ... +        // But when this snapshot base class directly contains LockStatic, as +        // above, Visual Studio 2017 requires us to code instead: +        // for (auto& inst : std::move(T::instance_snapshot())) ... +        // nat thinks this should be unnecessary, as an anonymous class +        // instance is already a temporary. It shouldn't need to be cast to +        // rvalue reference (the role of std::move()). clang evidently agrees, +        // as the short form works fine with Xcode on Mac. +        // To support the succinct usage, instead of directly storing +        // LockStatic, store std::shared_ptr<LockStatic>, which is copyable. +        std::shared_ptr<LockStatic> mLockp{std::make_shared<LockStatic>()}; +        LockStatic& mLock{*mLockp}; +#endif // LL_WINDOWS          VectorType mData;      }; @@ -373,7 +390,24 @@ public:                              strong_iterator(mData.end(), strengthen));          } -        LockStatic mLock;           // lock static data during construction +        // lock static data during construction +#if ! LL_WINDOWS +        LockStatic mLock; +#else  // LL_WINDOWS +        // We want to be able to use our instance_snapshot subclass as: +        // for (auto& inst : T::instance_snapshot()) ... +        // But when this snapshot base class directly contains LockStatic, as +        // above, Visual Studio 2017 requires us to code instead: +        // for (auto& inst : std::move(T::instance_snapshot())) ... +        // nat thinks this should be unnecessary, as an anonymous class +        // instance is already a temporary. It shouldn't need to be cast to +        // rvalue reference (the role of std::move()). clang evidently agrees, +        // as the short form works fine with Xcode on Mac. +        // To support the succinct usage, instead of directly storing +        // LockStatic, store std::shared_ptr<LockStatic>, which is copyable. +        std::shared_ptr<LockStatic> mLockp{std::make_shared<LockStatic>()}; +        LockStatic& mLock{*mLockp}; +#endif // LL_WINDOWS          VectorType mData;      }; | 
