summaryrefslogtreecommitdiff
path: root/storage/innobase/include
diff options
context:
space:
mode:
authorEugene Kosov <claprix@yandex.ru>2020-03-18 15:19:45 +0300
committerEugene Kosov <claprix@yandex.ru>2020-03-20 21:35:42 +0300
commit1f53335d3740648c167b5d0a8217b66731228395 (patch)
tree00b802eafaea818014f42f1eebb0126ca549b768 /storage/innobase/include
parent884d22f28884e1decced1dee9c69ddcb25002ed1 (diff)
downloadmariadb-git-1f53335d3740648c167b5d0a8217b66731228395.tar.gz
st_::span fixes
move span.h to a proper place to make it available for the whole server Reformat it. Constuctors from a contigous container are fixed to use cont.data() instead of cont.begin() span<>::index_type is replaced with span<>::size_type
Diffstat (limited to 'storage/innobase/include')
-rw-r--r--storage/innobase/include/span.h145
1 files changed, 0 insertions, 145 deletions
diff --git a/storage/innobase/include/span.h b/storage/innobase/include/span.h
deleted file mode 100644
index 62bcd80acd5..00000000000
--- a/storage/innobase/include/span.h
+++ /dev/null
@@ -1,145 +0,0 @@
-/*****************************************************************************
-
-Copyright (c) 2019, 2020 MariaDB Corporation.
-
-This program is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free Software
-Foundation; version 2 of the License.
-
-This program is distributed in the hope that it will be useful, but WITHOUT
-ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License along with
-this program; if not, write to the Free Software Foundation, Inc.,
-51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA
-
-*****************************************************************************/
-
-#pragma once
-
-#include <cstddef>
-#include <iterator>
-
-namespace st_ {
-
-template <class ElementType> class span {
-public:
- typedef ElementType element_type;
- typedef ElementType value_type;
- typedef size_t index_type;
- typedef ptrdiff_t difference_type;
- typedef element_type* pointer;
- typedef const element_type* const_pointer;
- typedef element_type& reference;
- typedef const element_type& const_reference;
- typedef pointer iterator;
- typedef const_pointer const_iterator;
- typedef std::reverse_iterator<iterator> reverse_iterator;
- typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
-
- span() : data_(NULL), size_(0) {}
-
- span(pointer ptr, index_type count) : data_(ptr), size_(count) {}
-
- span(pointer first, pointer last) : data_(first), size_(last - first) {}
-
- template <size_t N> span(element_type (&arr)[N]) : data_(arr), size_(N)
- {
- }
-
- template <class Container>
- span(Container& cont) : data_(cont.begin()), size_(cont.size())
- {
- }
-
- template <class Container>
- span(const Container& cont) : data_(cont.begin()), size_(cont.size())
- {
- }
-
- span(const span& other) : data_(other.data_), size_(other.size_) {}
-
- ~span(){};
-
- span& operator=(const span& other)
- {
- data_ = other.data_;
- size_ = other.size_;
- return *this;
- }
-
- template <size_t Count> span<element_type> first() const
- {
- assert(!empty());
- return span(data_, 1);
- }
- template <size_t Count> span<element_type> last() const
- {
- assert(!empty());
- return span(data_ + size() - 1, 1);
- }
-
- span<element_type> first(index_type count) const
- {
- assert(!empty());
- return span(data_, 1);
- }
- span<element_type> last(index_type count) const
- {
- assert(!empty());
- return span(data_ + size() - 1, 1);
- }
- span<element_type> subspan(index_type offset, index_type count) const
- {
- assert(!empty());
- assert(size() >= offset + count);
- return span(data_ + offset, count);
- }
-
- index_type size() const { return size_; }
- index_type size_bytes() const { return size_ * sizeof(ElementType); }
- bool empty() const __attribute__((warn_unused_result))
- {
- return size_ == 0;
- }
-
- reference operator[](index_type idx) const
- {
- assert(size() > idx);
- return data_[idx];
- }
- reference front() const
- {
- assert(!empty());
- return data_[0];
- }
- reference back() const
- {
- assert(!empty());
- return data_[size() - 1];
- }
- pointer data() const
- {
- assert(!empty());
- return data_;
- }
-
- iterator begin() const { return data_; }
- iterator end() const { return data_ + size_; }
- reverse_iterator rbegin() const
- {
- return std::reverse_iterator<iterator>(std::advance(end(), -1));
- }
- reverse_iterator rend() const
- {
- return std::reverse_iterator<iterator>(
- std::advance(begin(), -1));
- }
-
-private:
- pointer data_;
- index_type size_;
-};
-
-} // namespace st_