diff options
author | Andrey Lihatskiy <alihatskiy@productengine.com> | 2023-05-17 17:47:45 +0300 |
---|---|---|
committer | Andrey Lihatskiy <alihatskiy@productengine.com> | 2023-05-17 17:47:45 +0300 |
commit | 4dcab10bf8a652c6513bf6c9eec3184f79d4d219 (patch) | |
tree | 3cb870beefc8c0488532e0b424450780357ed7f5 /indra/llcommon/llsd.h | |
parent | 42f16180a985fc0e4704a4e25489ada9d662631a (diff) | |
parent | 5a70639b7992842a9f74ec81b11bac56608b8f2e (diff) |
Merge branch 'main' into DRTVWR-580-maint-T
# Conflicts:
# doc/contributions.txt
# indra/llcharacter/llkeyframemotion.cpp
# indra/newview/llfilepicker.cpp
Diffstat (limited to 'indra/llcommon/llsd.h')
-rw-r--r-- | indra/llcommon/llsd.h | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/indra/llcommon/llsd.h b/indra/llcommon/llsd.h index 3daaef44fc..cdb9a7ed8a 100644 --- a/indra/llcommon/llsd.h +++ b/indra/llcommon/llsd.h @@ -192,7 +192,17 @@ public: /** @name Convenience Constructors */ //@{ - LLSD(F32); // F32 -> Real + // support construction from size_t et al. + template <typename VALUE, + typename std::enable_if<std::is_integral<VALUE>::value && + ! std::is_same<VALUE, Boolean>::value, + bool>::type = true> + LLSD(VALUE v): LLSD(Integer(narrow(v))) {} + // support construction from F32 et al. + template <typename VALUE, + typename std::enable_if<std::is_floating_point<VALUE>::value, + bool>::type = true> + LLSD(VALUE v): LLSD(Real(narrow(v))) {} //@} /** @name Scalar Assignment */ @@ -275,7 +285,7 @@ public: //@{ LLSD(const char*); void assign(const char*); - LLSD& operator=(const char* v) { assign(v); return *this; } + LLSD& operator=(const char* v) { assign(v); return *this; } //@} /** @name Map Values */ @@ -313,14 +323,24 @@ public: LLSD& append(const LLSD&); void erase(Integer); LLSD& with(Integer, const LLSD&); - - const LLSD& operator[](Integer) const; - LLSD& operator[](Integer); + + // accept size_t so we can index relative to size() + const LLSD& operator[](size_t) const; + LLSD& operator[](size_t); + // template overloads to support int literals, U32 et al. + template <typename IDX, + typename std::enable_if<std::is_convertible<IDX, size_t>::value, + bool>::type = true> + const LLSD& operator[](IDX i) const { return (*this)[size_t(i)]; } + template <typename IDX, + typename std::enable_if<std::is_convertible<IDX, size_t>::value, + bool>::type = true> + LLSD& operator[](IDX i) { return (*this)[size_t(i)]; } //@} /** @name Iterators */ //@{ - int size() const; + size_t size() const; typedef std::map<String, LLSD>::iterator map_iterator; typedef std::map<String, LLSD>::const_iterator map_const_iterator; |