1
0
Fork 0
mirror of https://github.com/bolero-MURAKAMI/Sprout synced 2025-08-03 12:49:50 +00:00

adapt div_t container interface

This commit is contained in:
bolero-MURAKAMI 2016-04-04 01:49:57 +09:00
parent 478c21a300
commit 913dc8ca44
6 changed files with 319 additions and 49 deletions

View file

@ -175,77 +175,77 @@ namespace sprout {
}
};
template<typename Container1, typename Container2, bool C>
template<typename Container1, typename Container2, bool C, typename Subscript>
inline SPROUT_CONSTEXPR typename std::enable_if<
std::is_same<typename std::decay<Container1>::type, typename std::decay<Container2>::type>::value,
bool
>::type
operator==(sprout::index_iterator<Container1, C> const& lhs, sprout::index_iterator<Container2, C> const& rhs) {
operator==(sprout::index_iterator<Container1, C, Subscript> const& lhs, sprout::index_iterator<Container2, C, Subscript> const& rhs) {
return lhs.index() == rhs.index();
}
template<typename Container1, typename Container2, bool C>
template<typename Container1, typename Container2, bool C, typename Subscript>
inline SPROUT_CONSTEXPR typename std::enable_if<
std::is_same<typename std::decay<Container1>::type, typename std::decay<Container2>::type>::value,
bool
>::type
operator!=(sprout::index_iterator<Container1, C> const& lhs, sprout::index_iterator<Container2, C> const& rhs) {
operator!=(sprout::index_iterator<Container1, C, Subscript> const& lhs, sprout::index_iterator<Container2, C, Subscript> const& rhs) {
return !(lhs == rhs);
}
template<typename Container1, typename Container2, bool C>
template<typename Container1, typename Container2, bool C, typename Subscript>
inline SPROUT_CONSTEXPR typename std::enable_if<
std::is_same<typename std::decay<Container1>::type, typename std::decay<Container2>::type>::value,
bool
>::type
operator<(sprout::index_iterator<Container1, C> const& lhs, sprout::index_iterator<Container2, C> const& rhs) {
operator<(sprout::index_iterator<Container1, C, Subscript> const& lhs, sprout::index_iterator<Container2, C, Subscript> const& rhs) {
return lhs.index() < rhs.index();
}
template<typename Container1, typename Container2, bool C>
template<typename Container1, typename Container2, bool C, typename Subscript>
inline SPROUT_CONSTEXPR typename std::enable_if<
std::is_same<typename std::decay<Container1>::type, typename std::decay<Container2>::type>::value,
bool
>::type
operator>(sprout::index_iterator<Container1, C> const& lhs, sprout::index_iterator<Container2, C> const& rhs) {
operator>(sprout::index_iterator<Container1, C, Subscript> const& lhs, sprout::index_iterator<Container2, C, Subscript> const& rhs) {
return rhs < lhs;
}
template<typename Container1, typename Container2, bool C>
template<typename Container1, typename Container2, bool C, typename Subscript>
inline SPROUT_CONSTEXPR typename std::enable_if<
std::is_same<typename std::decay<Container1>::type, typename std::decay<Container2>::type>::value,
bool
>::type
operator<=(sprout::index_iterator<Container1, C> const& lhs, sprout::index_iterator<Container2, C> const& rhs) {
operator<=(sprout::index_iterator<Container1, C, Subscript> const& lhs, sprout::index_iterator<Container2, C, Subscript> const& rhs) {
return !(rhs < lhs);
}
template<typename Container1, typename Container2, bool C>
template<typename Container1, typename Container2, bool C, typename Subscript>
inline SPROUT_CONSTEXPR typename std::enable_if<
std::is_same<typename std::decay<Container1>::type, typename std::decay<Container2>::type>::value,
bool
>::type
operator>=(sprout::index_iterator<Container1, C> const& lhs, sprout::index_iterator<Container2, C> const& rhs) {
operator>=(sprout::index_iterator<Container1, C, Subscript> const& lhs, sprout::index_iterator<Container2, C, Subscript> const& rhs) {
return !(lhs < rhs);
}
template<typename Container1, typename Container2, bool C>
template<typename Container1, typename Container2, bool C, typename Subscript>
inline SPROUT_CONSTEXPR typename std::enable_if<
std::is_same<typename std::decay<Container1>::type, typename std::decay<Container2>::type>::value,
decltype(
std::declval<typename std::iterator_traits<sprout::index_iterator<Container1, C> >::difference_type>()
- std::declval<typename std::iterator_traits<sprout::index_iterator<Container2, C> >::difference_type>()
std::declval<typename std::iterator_traits<sprout::index_iterator<Container1, C, Subscript> >::difference_type>()
- std::declval<typename std::iterator_traits<sprout::index_iterator<Container2, C, Subscript> >::difference_type>()
)
>::type
operator-(sprout::index_iterator<Container1, C> const& lhs, sprout::index_iterator<Container2, C> const& rhs) {
operator-(sprout::index_iterator<Container1, C, Subscript> const& lhs, sprout::index_iterator<Container2, C, Subscript> const& rhs) {
return lhs.index() - rhs.index();
}
template<typename Container, bool C>
inline SPROUT_CONSTEXPR sprout::index_iterator<Container, C>
operator+(typename sprout::index_iterator<Container, C>::difference_type n, sprout::index_iterator<Container, C> const& it) {
template<typename Container, bool C, typename Subscript>
inline SPROUT_CONSTEXPR sprout::index_iterator<Container, C, Subscript>
operator+(typename sprout::index_iterator<Container, C, Subscript>::difference_type n, sprout::index_iterator<Container, C, Subscript> const& it) {
return it + n;
}
//
// swap
//
template<typename Container, bool C>
template<typename Container, bool C, typename Subscript>
inline SPROUT_CXX14_CONSTEXPR void
swap(sprout::index_iterator<Container, C>& lhs, sprout::index_iterator<Container, C>& rhs)
swap(sprout::index_iterator<Container, C, Subscript>& lhs, sprout::index_iterator<Container, C, Subscript>& rhs)
SPROUT_NOEXCEPT_IF_EXPR(lhs.swap(rhs))
{
lhs.swap(rhs);
@ -266,34 +266,34 @@ namespace sprout {
struct is_index_iterator<T const volatile>
: public sprout::is_index_iterator<T>
{};
template<typename Container, bool C>
struct is_index_iterator<sprout::index_iterator<Container, C> >
template<typename Container, bool C, typename Subscript>
struct is_index_iterator<sprout::index_iterator<Container, C, Subscript> >
: public sprout::true_type
{};
//
// iterator_next
//
template<typename Container, bool C>
inline SPROUT_CONSTEXPR sprout::index_iterator<Container, C>
iterator_next(sprout::index_iterator<Container, C> const& it) {
template<typename Container, bool C, typename Subscript>
inline SPROUT_CONSTEXPR sprout::index_iterator<Container, C, Subscript>
iterator_next(sprout::index_iterator<Container, C, Subscript> const& it) {
return it.next();
}
//
// iterator_prev
//
template<typename Container, bool C>
inline SPROUT_CONSTEXPR sprout::index_iterator<Container, C>
iterator_prev(sprout::index_iterator<Container, C> const& it) {
template<typename Container, bool C, typename Subscript>
inline SPROUT_CONSTEXPR sprout::index_iterator<Container, C, Subscript>
iterator_prev(sprout::index_iterator<Container, C, Subscript> const& it) {
return it.prev();
}
//
// is_const_iterator_cast_convertible
//
template<typename FromContainer, typename ToContainer, bool C>
struct is_const_iterator_cast_convertible<sprout::index_iterator<FromContainer, C>, sprout::index_iterator<ToContainer, C> >
template<typename FromContainer, typename ToContainer, bool C, typename Subscript>
struct is_const_iterator_cast_convertible<sprout::index_iterator<FromContainer, C, Subscript>, sprout::index_iterator<ToContainer, C, Subscript> >
: public std::is_same<typename std::decay<FromContainer>::type, typename std::decay<ToContainer>::type>
{};
//
@ -301,11 +301,11 @@ namespace sprout {
//
template<
typename T,
typename Container, bool C,
typename sprout::enabler_if<sprout::is_const_iterator_cast_convertible<sprout::index_iterator<Container, C>, T>::value>::type = sprout::enabler
typename Container, bool C, typename Subscript,
typename sprout::enabler_if<sprout::is_const_iterator_cast_convertible<sprout::index_iterator<Container, C, Subscript>, T>::value>::type = sprout::enabler
>
inline SPROUT_CONSTEXPR T
const_iterator_conversion(sprout::index_iterator<Container, C> const& it) {
const_iterator_conversion(sprout::index_iterator<Container, C, Subscript> const& it) {
return T(const_cast<typename T::container_type>(it.base()), it.index());
}
} // namespace sprout