util: Use ctor inheritance in set.h
([arc::pullid] c27e404e-1839bf91-71eebab5-52f9d7fb)
template <class K, class L, class A>
class TSet: public std::set<K, L, TReboundAllocator<A, K>> {
- using TBase = std::set<K, L, TReboundAllocator<A, K>>;
- using TSelf = TSet<K, L, A>;
- using TKeyCompare = typename TBase::key_compare;
- using TAllocatorType = typename TBase::allocator_type;
-
public:
- inline TSet() {
- }
-
- template <typename TAllocParam>
- inline explicit TSet(TAllocParam* allocator)
- : TBase(TKeyCompare(), allocator)
- {
- }
-
- template <class It>
- inline TSet(It f, It l)
- : TBase(f, l)
- {
- }
-
- inline TSet(std::initializer_list<K> il, const TKeyCompare& comp = TKeyCompare(), const TAllocatorType& alloc = TAllocatorType())
- : TBase(il, comp, alloc)
- {
- }
-
- inline TSet(const TSelf& src)
- : TBase(src)
- {
- }
-
- inline TSet(TSelf&& src) noexcept
- : TBase(std::forward<TSelf>(src))
- {
- }
-
- inline TSelf& operator=(const TSelf& src) {
- TBase::operator=(src);
- return *this;
- }
-
- inline TSelf& operator=(TSelf&& src) noexcept {
- TBase::operator=(std::forward<TSelf>(src));
- return *this;
- }
-
- Y_PURE_FUNCTION
- inline bool empty() const noexcept {
- return TBase::empty();
- }
+ using TBase = std::set<K, L, TReboundAllocator<A, K>>;
+ using TBase::TBase;
inline explicit operator bool() const noexcept {
return !this->empty();
@@ -74,53 +27,9 @@ public:
template <class K, class L, class A>
class TMultiSet: public std::multiset<K, L, TReboundAllocator<A, K>> {
- using TBase = std::multiset<K, L, TReboundAllocator<A, K>>;
- using TSelf = TMultiSet<K, L, A>;
- using TKeyCompare = typename TBase::key_compare;
- using TAllocatorType = typename TBase::allocator_type;
-
public:
- inline TMultiSet() {
- }
-
- template <class It>
- inline TMultiSet(It f, It l)
- : TBase(f, l)
- {
- }
-
- inline TMultiSet(std::initializer_list<K> il, const TKeyCompare& comp = TKeyCompare(), const TAllocatorType& alloc = TAllocatorType())
- : TBase(il, comp, alloc)
- {
- }
-
- inline TMultiSet(const TSelf& src)
- : TBase(src)
- {
- }
-
- inline TMultiSet(TSelf&& src) noexcept {
- this->swap(src);
- }
-
- inline TSelf& operator=(const TSelf& src) {
- TBase::operator=(src);
- return *this;
- }
-
- inline TSelf& operator=(TSelf&& src) noexcept {
- // Self-move assignment is undefined behavior in the Standard.
- // This implementation ends up with zero-sized multiset.
- this->clear();
- this->swap(src);
-
- return *this;
- }
-
- Y_PURE_FUNCTION
- inline bool empty() const noexcept {
- return TBase::empty();
- }
+ using TBase = std::multiset<K, L, TReboundAllocator<A, K>>;
+ using TBase::TBase;
inline explicit operator bool() const noexcept {
return !this->empty();
