aboutsummaryrefslogtreecommitdiffstats
path: root/util/generic/adaptor.h
diff options
context:
space:
mode:
authorAlexander Fokin <apfokin@gmail.com>2022-02-10 16:45:38 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:38 +0300
commitbf9e69a933f89af083d895185f01ed65e4d90766 (patch)
treeb2cc84ee7850122e7ccf51d0ea21e4fa7e7a5685 /util/generic/adaptor.h
parent863a59a65247c24db7cb06789bc5cf79d04da32f (diff)
downloadydb-bf9e69a933f89af083d895185f01ed65e4d90766.tar.gz
Restoring authorship annotation for Alexander Fokin <apfokin@gmail.com>. Commit 2 of 2.
Diffstat (limited to 'util/generic/adaptor.h')
-rw-r--r--util/generic/adaptor.h150
1 files changed, 75 insertions, 75 deletions
diff --git a/util/generic/adaptor.h b/util/generic/adaptor.h
index 0c5aa16c87..b88a65fc81 100644
--- a/util/generic/adaptor.h
+++ b/util/generic/adaptor.h
@@ -5,136 +5,136 @@
namespace NPrivate {
template <class Range>
- class TReverseRangeStorage {
- public:
+ class TReverseRangeStorage {
+ public:
TReverseRangeStorage(Range&& range)
: Base_(std::forward<Range>(range))
{
}
- decltype(auto) Base() const {
- return *Base_.Ptr();
- }
-
- decltype(auto) Base() {
- return *Base_.Ptr();
- }
-
- private:
- TAutoEmbedOrPtrPolicy<Range> Base_;
- };
-
- template <class Range>
- constexpr bool HasReverseIterators(i32, decltype(std::declval<Range>().rbegin())*) {
- return true;
- }
-
- template <class Range>
- constexpr bool HasReverseIterators(char, std::nullptr_t*) {
- return false;
- }
-
- template <class Range, bool hasReverseIterators = HasReverseIterators<Range>((i32)0, nullptr)>
- class TReverseRangeBase: public TReverseRangeStorage<Range> {
- using TBase = TReverseRangeStorage<Range>;
-
- public:
+ decltype(auto) Base() const {
+ return *Base_.Ptr();
+ }
+
+ decltype(auto) Base() {
+ return *Base_.Ptr();
+ }
+
+ private:
+ TAutoEmbedOrPtrPolicy<Range> Base_;
+ };
+
+ template <class Range>
+ constexpr bool HasReverseIterators(i32, decltype(std::declval<Range>().rbegin())*) {
+ return true;
+ }
+
+ template <class Range>
+ constexpr bool HasReverseIterators(char, std::nullptr_t*) {
+ return false;
+ }
+
+ template <class Range, bool hasReverseIterators = HasReverseIterators<Range>((i32)0, nullptr)>
+ class TReverseRangeBase: public TReverseRangeStorage<Range> {
+ using TBase = TReverseRangeStorage<Range>;
+
+ public:
using TBase::Base;
- using TBase::TBase;
-
+ using TBase::TBase;
+
auto begin() const {
- return Base().rbegin();
+ return Base().rbegin();
}
auto end() const {
- return Base().rend();
+ return Base().rend();
}
auto begin() {
- return Base().rbegin();
+ return Base().rbegin();
}
auto end() {
- return Base().rend();
+ return Base().rend();
}
};
- template <class Range>
- class TReverseRangeBase<Range, false>: public TReverseRangeStorage<Range> {
- using TBase = TReverseRangeStorage<Range>;
+ template <class Range>
+ class TReverseRangeBase<Range, false>: public TReverseRangeStorage<Range> {
+ using TBase = TReverseRangeStorage<Range>;
- public:
+ public:
using TBase::Base;
- using TBase::TBase;
-
- auto begin() const {
+ using TBase::TBase;
+
+ auto begin() const {
using std::end;
- return std::make_reverse_iterator(end(Base()));
+ return std::make_reverse_iterator(end(Base()));
}
- auto end() const {
+ auto end() const {
using std::begin;
- return std::make_reverse_iterator(begin(Base()));
+ return std::make_reverse_iterator(begin(Base()));
}
- auto begin() {
+ auto begin() {
using std::end;
- return std::make_reverse_iterator(end(Base()));
+ return std::make_reverse_iterator(end(Base()));
}
- auto end() {
+ auto end() {
using std::begin;
- return std::make_reverse_iterator(begin(Base()));
+ return std::make_reverse_iterator(begin(Base()));
}
};
- template <class Range>
+ template <class Range>
class TReverseRange: public TReverseRangeBase<Range> {
- using TBase = TReverseRangeBase<Range>;
+ using TBase = TReverseRangeBase<Range>;
- public:
+ public:
using TBase::Base;
- using TBase::TBase;
+ using TBase::TBase;
- TReverseRange(TReverseRange&&) = default;
- TReverseRange(const TReverseRange&) = default;
+ TReverseRange(TReverseRange&&) = default;
+ TReverseRange(const TReverseRange&) = default;
auto rbegin() const {
using std::begin;
- return begin(Base());
+ return begin(Base());
}
auto rend() const {
using std::end;
- return end(Base());
+ return end(Base());
}
auto rbegin() {
using std::begin;
- return begin(Base());
+ return begin(Base());
}
auto rend() {
using std::end;
- return end(Base());
+ return end(Base());
}
};
}
-/**
- * Provides a reverse view into the provided container.
- *
- * Example usage:
- * @code
- * for(auto&& value: Reversed(container)) {
- * // use value here.
- * }
- * @endcode
- *
- * @param cont Container to provide a view into. Must be an lvalue.
- * @returns A reverse view into the provided container.
- */
-template <class Range>
-constexpr ::NPrivate::TReverseRange<Range> Reversed(Range&& range) {
- return ::NPrivate::TReverseRange<Range>(std::forward<Range>(range));
+/**
+ * Provides a reverse view into the provided container.
+ *
+ * Example usage:
+ * @code
+ * for(auto&& value: Reversed(container)) {
+ * // use value here.
+ * }
+ * @endcode
+ *
+ * @param cont Container to provide a view into. Must be an lvalue.
+ * @returns A reverse view into the provided container.
+ */
+template <class Range>
+constexpr ::NPrivate::TReverseRange<Range> Reversed(Range&& range) {
+ return ::NPrivate::TReverseRange<Range>(std::forward<Range>(range));
}