diff options
author | Anton Samokhvalov <pg83@yandex.ru> | 2022-02-10 16:45:15 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:15 +0300 |
commit | 72cb13b4aff9bc9cf22e49251bc8fd143f82538f (patch) | |
tree | da2c34829458c7d4e74bdfbdf85dff449e9e7fb8 /library/cpp/deprecated/accessors/accessors_impl.h | |
parent | 778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5 (diff) | |
download | ydb-72cb13b4aff9bc9cf22e49251bc8fd143f82538f.tar.gz |
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/deprecated/accessors/accessors_impl.h')
-rw-r--r-- | library/cpp/deprecated/accessors/accessors_impl.h | 254 |
1 files changed, 127 insertions, 127 deletions
diff --git a/library/cpp/deprecated/accessors/accessors_impl.h b/library/cpp/deprecated/accessors/accessors_impl.h index 6b2b987351..e04cc0679f 100644 --- a/library/cpp/deprecated/accessors/accessors_impl.h +++ b/library/cpp/deprecated/accessors/accessors_impl.h @@ -3,114 +3,114 @@ #include "memory_traits.h" namespace NAccessors { - namespace NPrivate { - template <typename Ta> - struct TMemoryAccessorBase { - enum { - SimpleMemory = TMemoryTraits<Ta>::SimpleMemory, - ContinuousMemory = TMemoryTraits<Ta>::ContinuousMemory, - }; - - struct TBadAccessor; - }; - - template <typename Ta> - struct TBegin: public TMemoryAccessorBase<Ta> { + namespace NPrivate { + template <typename Ta> + struct TMemoryAccessorBase { + enum { + SimpleMemory = TMemoryTraits<Ta>::SimpleMemory, + ContinuousMemory = TMemoryTraits<Ta>::ContinuousMemory, + }; + + struct TBadAccessor; + }; + + template <typename Ta> + struct TBegin: public TMemoryAccessorBase<Ta> { using TElementType = typename TMemoryTraits<Ta>::TElementType; - template <typename Tb> - struct TNoMemoryIndirectionBegin { - static const TElementType* Get(const Tb& b) { - return (const TElementType*)&b; - } - }; + template <typename Tb> + struct TNoMemoryIndirectionBegin { + static const TElementType* Get(const Tb& b) { + return (const TElementType*)&b; + } + }; - template <typename Tb> - struct TIndirectMemoryRegionBegin { + template <typename Tb> + struct TIndirectMemoryRegionBegin { Y_HAS_MEMBER(Begin); Y_HAS_MEMBER(begin); - template <typename Tc> - struct TByBegin { - static const TElementType* Get(const Tc& b) { - return (const TElementType*)b.Begin(); - } - }; - - template <typename Tc> - struct TBybegin { - static const TElementType* Get(const Tc& b) { - return (const TElementType*)b.begin(); - } - }; - + template <typename Tc> + struct TByBegin { + static const TElementType* Get(const Tc& b) { + return (const TElementType*)b.Begin(); + } + }; + + template <typename Tc> + struct TBybegin { + static const TElementType* Get(const Tc& b) { + return (const TElementType*)b.begin(); + } + }; + using TGet = std::conditional_t<THasBegin<Tb>::value, TByBegin<Tb>, TBybegin<Tb>>; - - static const TElementType* Get(const Tb& b) { - return TGet::Get(b); - } - }; - + + static const TElementType* Get(const Tb& b) { + return TGet::Get(b); + } + }; + using TGet = std::conditional_t< - TMemoryAccessorBase<Ta>::SimpleMemory, - TNoMemoryIndirectionBegin<Ta>, + TMemoryAccessorBase<Ta>::SimpleMemory, + TNoMemoryIndirectionBegin<Ta>, std::conditional_t< - TMemoryAccessorBase<Ta>::ContinuousMemory, - TIndirectMemoryRegionBegin<Ta>, + TMemoryAccessorBase<Ta>::ContinuousMemory, + TIndirectMemoryRegionBegin<Ta>, typename TMemoryAccessorBase<Ta>::TBadAccessor>>; - - static const TElementType* Get(const Ta& b) { - return TGet::Get(b); + + static const TElementType* Get(const Ta& b) { + return TGet::Get(b); } }; - template <typename Ta> - struct TEnd: public TMemoryAccessorBase<Ta> { + template <typename Ta> + struct TEnd: public TMemoryAccessorBase<Ta> { using TElementType = typename TMemoryTraits<Ta>::TElementType; - template <typename Tb> - struct TNoMemoryIndirectionEnd { - static const TElementType* Get(const Tb& b) { - return (const TElementType*)(&b + 1); - } - }; + template <typename Tb> + struct TNoMemoryIndirectionEnd { + static const TElementType* Get(const Tb& b) { + return (const TElementType*)(&b + 1); + } + }; - template <typename Tb> - struct TIndirectMemoryRegionEnd { + template <typename Tb> + struct TIndirectMemoryRegionEnd { Y_HAS_MEMBER(End); Y_HAS_MEMBER(end); - template <typename Tc> - struct TByEnd { - static const TElementType* Get(const Tc& b) { - return (const TElementType*)b.End(); - } - }; + template <typename Tc> + struct TByEnd { + static const TElementType* Get(const Tc& b) { + return (const TElementType*)b.End(); + } + }; - template <typename Tc> - struct TByend { - static const TElementType* Get(const Tc& b) { - return (const TElementType*)b.end(); - } - }; + template <typename Tc> + struct TByend { + static const TElementType* Get(const Tc& b) { + return (const TElementType*)b.end(); + } + }; using TGet = std::conditional_t<THasEnd<Tb>::value, TByEnd<Tb>, TByend<Tb>>; - static const TElementType* Get(const Tb& b) { - return TGet::Get(b); - } - }; + static const TElementType* Get(const Tb& b) { + return TGet::Get(b); + } + }; using TGet = std::conditional_t< - TMemoryAccessorBase<Ta>::SimpleMemory, - TNoMemoryIndirectionEnd<Ta>, + TMemoryAccessorBase<Ta>::SimpleMemory, + TNoMemoryIndirectionEnd<Ta>, std::conditional_t< - TMemoryAccessorBase<Ta>::ContinuousMemory, - TIndirectMemoryRegionEnd<Ta>, + TMemoryAccessorBase<Ta>::ContinuousMemory, + TIndirectMemoryRegionEnd<Ta>, typename TMemoryAccessorBase<Ta>::TBadAccessor>>; - static const TElementType* Get(const Ta& b) { - return TGet::Get(b); + static const TElementType* Get(const Ta& b) { + return TGet::Get(b); } }; @@ -343,13 +343,13 @@ namespace NAccessors { } }; - template <typename Ta> - struct TAssign: public TMemoryAccessorBase<Ta> { + template <typename Ta> + struct TAssign: public TMemoryAccessorBase<Ta> { using TElementType = typename TMemoryTraits<Ta>::TElementType; - template <typename Tb> - struct TNoMemoryIndirectionAssign { - static void Do(Tb& b, const TElementType* beg, const TElementType* end) { + template <typename Tb> + struct TNoMemoryIndirectionAssign { + static void Do(Tb& b, const TElementType* beg, const TElementType* end) { if (sizeof(Tb) == sizeof(TElementType) && end - beg > 0) { memcpy(&b, beg, sizeof(Tb)); } else if (end - beg > 0) { @@ -357,63 +357,63 @@ namespace NAccessors { } else { Zero(b); } - } - }; + } + }; - template <typename Tb> - struct TIndirectMemoryRegionAssign { + template <typename Tb> + struct TIndirectMemoryRegionAssign { Y_HAS_MEMBER(Assign); Y_HAS_MEMBER(assign); - template <typename Tc> - struct TByAssign { - static void Do(Tc& b, const TElementType* beg, const TElementType* end) { - b.Assign(beg, end); - } - }; - - template <typename Tc> - struct TByassign { - static void Do(Tc& b, const TElementType* beg, const TElementType* end) { - b.assign(beg, end); - } - }; - - template <typename Tc> - struct TByClearAppend { - static void Do(Tc& b, const TElementType* beg, const TElementType* end) { - TClear<Tc, false>::Do(b); - TAppendRegion<Tc>::Do(b, beg, end); - } - }; - - template <typename Tc> - struct TByConstruction { - static void Do(Tc& b, const TElementType* beg, const TElementType* end) { - b = Tc(beg, end); - } - }; + template <typename Tc> + struct TByAssign { + static void Do(Tc& b, const TElementType* beg, const TElementType* end) { + b.Assign(beg, end); + } + }; + + template <typename Tc> + struct TByassign { + static void Do(Tc& b, const TElementType* beg, const TElementType* end) { + b.assign(beg, end); + } + }; + + template <typename Tc> + struct TByClearAppend { + static void Do(Tc& b, const TElementType* beg, const TElementType* end) { + TClear<Tc, false>::Do(b); + TAppendRegion<Tc>::Do(b, beg, end); + } + }; + + template <typename Tc> + struct TByConstruction { + static void Do(Tc& b, const TElementType* beg, const TElementType* end) { + b = Tc(beg, end); + } + }; using TDo = std::conditional_t< THasAssign<Tb>::value, - TByAssign<Tb>, + TByAssign<Tb>, std::conditional_t< THasassign<Tb>::value, - TByassign<Tb>, + TByassign<Tb>, std::conditional_t< - TMemoryTraits<Tb>::OwnsMemory, - TByClearAppend<Tb>, + TMemoryTraits<Tb>::OwnsMemory, + TByClearAppend<Tb>, TByConstruction<Tb>>>>; - static void Do(Tb& b, const TElementType* beg, const TElementType* end) { - TDo::Do(b, beg, end); - } - }; + static void Do(Tb& b, const TElementType* beg, const TElementType* end) { + TDo::Do(b, beg, end); + } + }; using TDo = std::conditional_t<TMemoryAccessorBase<Ta>::SimpleMemory, TNoMemoryIndirectionAssign<Ta>, TIndirectMemoryRegionAssign<Ta>>; - static void Do(Ta& b, const TElementType* beg, const TElementType* end) { - TDo::Do(b, beg, end); + static void Do(Ta& b, const TElementType* beg, const TElementType* end) { + TDo::Do(b, beg, end); } }; } |