Brett 2024-09-30 19:43:02 -04:00
parent 22c44ca551
commit 97b6efb1ff
3 changed files with 39 additions and 22 deletions

View File

@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.20)
include(cmake/color.cmake)
set(BLT_VERSION 1.1.5)
set(BLT_VERSION 1.1.6)
set(BLT_TARGET BLT)

View File

@ -129,7 +129,7 @@ namespace blt::iterator
}
};
namespace impls
namespace impl
{
template<typename Derived>
class skip_t
@ -227,13 +227,13 @@ namespace blt::iterator
};
}
template<typename IterBase, typename... Base>
class iterator_container : public impls::take_t<iterator_container<IterBase, Base...>>,
public impls::skip_t<iterator_container<IterBase, Base...>>,
public Base ...
template<typename IterBase>
class iterator_container : public impl::take_t<iterator_container<IterBase>>,
public impl::skip_t<iterator_container<IterBase>>
{
public:
using iterator_category = typename IterBase::iterator_category;
using iterator = IterBase;
iterator_container(IterBase begin, IterBase end): m_begin(std::move(begin)), m_end(std::move(end))
{}
@ -247,7 +247,8 @@ namespace blt::iterator
static_assert((std::is_same_v<typename IterBase::iterator_category, std::bidirectional_iterator_tag> ||
std::is_same_v<typename IterBase::iterator_category, std::random_access_iterator_tag>),
".rev() must be used with bidirectional (or better) iterators!");
return iterator_container < std::reverse_iterator<IterBase>, Base...>{std::reverse_iterator<IterBase>{end()}, std::reverse_iterator<IterBase>{begin()}};
return iterator_container<std::reverse_iterator<IterBase>>{std::reverse_iterator<IterBase>{end()},
std::reverse_iterator<IterBase>{begin()}};
}
auto begin() const

View File

@ -97,6 +97,18 @@ namespace blt
return min;
}
};
// template<typename Iter>
// struct zip_wrapper<Iter> : public Iter
// {
// using iterator_category = typename std::iterator_traits<Iter>::iterator_category;
// using value_type = typename std::iterator_traits<Iter>::value_type;
// using difference_type = typename std::iterator_traits<Iter>::difference_type;
// using pointer = typename std::iterator_traits<Iter>::pointer;
// using reference = typename std::iterator_traits<Iter>::reference;
//
// using Iter::Iter;
// };
}
template<typename Iter>
@ -112,38 +124,42 @@ namespace blt
};
template<typename... Iter>
class zip_iterator_storage : public iterator::iterator_container<iterator::zip_wrapper<Iter...>>
class zip_iterator_container : public iterator::iterator_container<iterator::zip_wrapper<Iter...>>
{
public:
using iterator::iterator_container<iterator::zip_wrapper<Iter...>>::iterator_container;
explicit zip_iterator_storage(iterator_pair<Iter>... iterator_pairs):
explicit zip_iterator_container(iterator_pair<Iter>... iterator_pairs):
iterator::iterator_container<iterator::zip_wrapper<Iter...>>(iterator::zip_wrapper<Iter...>{std::move(iterator_pairs.begin)...},
iterator::zip_wrapper<Iter...>{std::move(iterator_pairs.end)...})
{}
};
template<typename Derived>
class zip_t
namespace impl
{
public:
template<typename... Iter>
auto zip(iterator_pair<Iter>... iterator_pairs)
{
iterator::iterator_container<iterator::zip_wrapper<Iter...>>(iterator::zip_wrapper<Iter...>{std::move(iterator_pairs.begin)...},
iterator::zip_wrapper<Iter...>{std::move(iterator_pairs.end)...});
}
};
template<typename Derived>
class zip_t
{
public:
template<typename... Iter>
auto zip(iterator_pair<Iter>... iterator_pairs)
{
zip_iterator_container(iterator::zip_wrapper<Iter...>{std::move(iterator_pairs.begin)...},
iterator::zip_wrapper<Iter...>{std::move(iterator_pairs.end)...});
}
};
}
/*
* CTAD for the zip containers
*/
template<typename... Iter>
zip_iterator_storage(iterator_pair<Iter>...) -> zip_iterator_storage<Iter...>;
zip_iterator_container(iterator_pair<Iter>...) -> zip_iterator_container<Iter...>;
template<typename... Iter>
zip_iterator_storage(std::initializer_list<Iter>...) -> zip_iterator_storage<Iter...>;
zip_iterator_container(std::initializer_list<Iter>...) -> zip_iterator_container<Iter...>;
/*
@ -153,7 +169,7 @@ namespace blt
template<typename... Container>
auto zip(Container& ... container)
{
return zip_iterator_storage{iterator_pair{container.begin(), container.end()}...};
return zip_iterator_container{iterator_pair{container.begin(), container.end()}...};
}
}