#pragma once #include #include namespace NRangeOps { template struct TRangeOpsBase { static inline void DestroyRange(T* b, T* e) noexcept { while (e > b) { (--e)->~T(); } } static inline void InitializeRange(T* b, T* e) { T* c = b; try { for (; c < e; ++c) { new (c) T(); } } catch (...) { DestroyRange(b, c); throw; } } }; template struct TRangeOpsBase { static inline void DestroyRange(T*, T*) noexcept { } static inline void InitializeRange(T*, T*) noexcept { } }; template using TRangeOps = TRangeOpsBase::IsPod>; template static inline void DestroyRange(T* b, T* e) noexcept { TRangeOps::DestroyRange(b, e); } template static inline void InitializeRange(T* b, T* e) { TRangeOps::InitializeRange(b, e); } }