晋太元中,武陵人捕鱼为业。缘溪行,忘路之远近。忽逢桃花林,夹岸数百步,中无杂树,芳草鲜美,落英缤纷。渔人甚异之,复前行,欲穷其林。 林尽水源,便得一山,山有小口,仿佛若有光。便舍船,从口入。初极狭,才通人。复行数十步,豁然开朗。土地平旷,屋舍俨然,有良田、美池、桑竹之属。阡陌交通,鸡犬相闻。其中往来种作,男女衣着,悉如外人。黄发垂髫,并怡然自乐。 见渔人,乃大惊,问所从来。具答之。便要还家,设酒杀鸡作食。村中闻有此人,咸来问讯。自云先世避秦时乱,率妻子邑人来此绝境,不复出焉,遂与外人间隔。问今是何世,乃不知有汉,无论魏晋。此人一一为具言所闻,皆叹惋。余人各复延至其家,皆出酒食。停数日,辞去。此中人语云:“不足为外人道也。”(间隔 一作:隔绝) 既出,得其船,便扶向路,处处志之。及郡下,诣太守,说如此。太守即遣人随其往,寻向所志,遂迷,不复得路。 南阳刘子骥,高尚士也,闻之,欣然规往。未果,寻病终。后遂无问津者。
| DIR:/proc/thread-self/root/usr/include/mysql/server/private/ |
| Current File : //proc/thread-self/root/usr/include/mysql/server/private/span.h |
/*****************************************************************************
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_
{
namespace detail
{
template <class T> struct remove_cv
{
typedef T type;
};
template <class T> struct remove_cv<const T>
{
typedef T type;
};
template <class T> struct remove_cv<volatile T>
{
typedef T type;
};
template <class T> struct remove_cv<const volatile T>
{
typedef T type;
};
} // namespace detail
template <class ElementType> class span
{
public:
typedef ElementType element_type;
typedef typename detail::remove_cv<ElementType>::type value_type;
typedef size_t size_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;
span() : data_(NULL), size_(0) {}
span(pointer ptr, size_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.data()), size_(cont.size())
{
}
template <class Container>
span(const Container &cont) : data_(cont.data()), size_(cont.size())
{
}
span(const span &other) : data_(other.data_), size_(other.size_) {}
~span() = default;
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(size_type count) const
{
assert(!empty());
return span(data(), 1);
}
span<element_type> last(size_type count) const
{
assert(!empty());
return span(data() + size() - 1, 1);
}
span<element_type> subspan(size_type offset, size_type count) const
{
assert(!empty());
assert(size() >= offset + count);
return span(data() + offset, count);
}
size_type size() const { return size_; }
size_type size_bytes() const { return size() * sizeof(ElementType); }
bool empty() const __attribute__((warn_unused_result))
{
return size() == 0;
}
reference operator[](size_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 { return data_; }
iterator begin() const { return data_; }
iterator end() const { return data_ + size_; }
reverse_iterator rbegin() const
{
return std::reverse_iterator<iterator>(end());
}
reverse_iterator rend() const
{
return std::reverse_iterator<iterator>(begin());
}
private:
pointer data_;
size_type size_;
};
} // namespace st_
|