2012-06-22 10:14:21 +00:00
|
|
|
#ifndef SPROUT_SUB_ARRAY_SUB_HPP
|
|
|
|
#define SPROUT_SUB_ARRAY_SUB_HPP
|
|
|
|
|
|
|
|
#include <type_traits>
|
|
|
|
#include <sprout/config.hpp>
|
|
|
|
#include <sprout/container/traits.hpp>
|
|
|
|
#include <sprout/container/functions.hpp>
|
|
|
|
#include <sprout/sub_array/sub_array.hpp>
|
|
|
|
#include <sprout/sub_array/type_traits.hpp>
|
2013-02-26 07:14:04 +00:00
|
|
|
#include <sprout/sub_array/sub_window.hpp>
|
2012-06-22 10:14:21 +00:00
|
|
|
|
|
|
|
namespace sprout {
|
|
|
|
//
|
|
|
|
// sub
|
|
|
|
//
|
|
|
|
template<typename Container>
|
2012-10-05 15:58:56 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename std::enable_if<!sprout::is_sub_array<Container>::value, sprout::sub_array<Container&> >::type
|
|
|
|
sub(
|
2012-06-22 10:14:21 +00:00
|
|
|
Container& arr,
|
|
|
|
typename sprout::container_traits<sprout::sub_array<Container&> >::const_iterator first,
|
|
|
|
typename sprout::container_traits<sprout::sub_array<Container&> >::const_iterator last
|
|
|
|
)
|
|
|
|
{
|
|
|
|
return sprout::sub_array<Container&>(arr, first, last);
|
|
|
|
}
|
|
|
|
template<typename Container>
|
2012-10-05 15:58:56 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename std::enable_if<!sprout::is_sub_array<Container>::value, sprout::sub_array<Container&> >::type
|
|
|
|
sub(
|
2012-06-22 10:14:21 +00:00
|
|
|
Container& arr,
|
|
|
|
typename sprout::container_traits<sprout::sub_array<Container&> >::const_iterator first
|
|
|
|
)
|
|
|
|
{
|
|
|
|
return sprout::sub(arr, first, sprout::end(arr));
|
|
|
|
}
|
|
|
|
template<typename Container>
|
2012-10-05 15:58:56 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename std::enable_if<!sprout::is_sub_array<Container>::value, sprout::sub_array<Container&> >::type
|
|
|
|
sub(
|
2012-06-22 10:14:21 +00:00
|
|
|
Container& arr,
|
2013-02-26 07:14:04 +00:00
|
|
|
typename sprout::container_traits<sprout::sub_array<Container&> >::difference_type to_first,
|
|
|
|
typename sprout::container_traits<sprout::sub_array<Container&> >::difference_type to_last
|
2012-06-22 10:14:21 +00:00
|
|
|
)
|
|
|
|
{
|
2013-02-26 07:14:04 +00:00
|
|
|
return sprout::sub_window(arr, to_first, to_last);
|
2012-06-22 10:14:21 +00:00
|
|
|
}
|
|
|
|
template<typename Container>
|
2012-10-05 15:58:56 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename std::enable_if<!sprout::is_sub_array<Container>::value, sprout::sub_array<Container&> >::type
|
|
|
|
sub(
|
2013-02-26 07:14:04 +00:00
|
|
|
Container& arr,
|
|
|
|
typename sprout::container_traits<sprout::sub_array<Container&> >::difference_type to_first = 0
|
2012-06-22 10:14:21 +00:00
|
|
|
)
|
|
|
|
{
|
2013-02-26 07:14:04 +00:00
|
|
|
return sprout::sub_window(arr, to_first);
|
2012-06-22 10:14:21 +00:00
|
|
|
}
|
2013-02-26 07:14:04 +00:00
|
|
|
|
2012-06-22 10:14:21 +00:00
|
|
|
template<typename Container>
|
2012-10-05 15:58:56 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename std::enable_if<!sprout::is_sub_array<Container>::value, sprout::sub_array<Container const&> >::type
|
|
|
|
sub(
|
2012-06-22 10:14:21 +00:00
|
|
|
Container const& arr,
|
|
|
|
typename sprout::container_traits<sprout::sub_array<Container const&> >::const_iterator first,
|
|
|
|
typename sprout::container_traits<sprout::sub_array<Container const&> >::const_iterator last
|
|
|
|
)
|
|
|
|
{
|
|
|
|
return sprout::sub_array<Container const&>(arr, first, last);
|
|
|
|
}
|
|
|
|
template<typename Container>
|
2012-10-05 15:58:56 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename std::enable_if<!sprout::is_sub_array<Container>::value, sprout::sub_array<Container const&> >::type
|
|
|
|
sub(
|
2012-06-22 10:14:21 +00:00
|
|
|
Container const& arr,
|
|
|
|
typename sprout::container_traits<sprout::sub_array<Container const&> >::const_iterator first
|
|
|
|
)
|
|
|
|
{
|
|
|
|
return sprout::sub(arr, first, sprout::end(arr));
|
|
|
|
}
|
|
|
|
template<typename Container>
|
2012-10-05 15:58:56 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename std::enable_if<!sprout::is_sub_array<Container>::value, sprout::sub_array<Container const&> >::type
|
|
|
|
sub(
|
2012-06-22 10:14:21 +00:00
|
|
|
Container const& arr,
|
2013-02-26 07:14:04 +00:00
|
|
|
typename sprout::container_traits<sprout::sub_array<Container const&> >::difference_type to_first,
|
|
|
|
typename sprout::container_traits<sprout::sub_array<Container const&> >::difference_type to_last
|
2012-06-22 10:14:21 +00:00
|
|
|
)
|
|
|
|
{
|
2013-02-26 07:14:04 +00:00
|
|
|
return sprout::sub_window(arr, to_first, to_last);
|
2012-06-22 10:14:21 +00:00
|
|
|
}
|
|
|
|
template<typename Container>
|
2012-10-05 15:58:56 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename std::enable_if<!sprout::is_sub_array<Container>::value, sprout::sub_array<Container const&> >::type
|
|
|
|
sub(
|
2013-02-26 07:14:04 +00:00
|
|
|
Container const& arr,
|
|
|
|
typename sprout::container_traits<sprout::sub_array<Container const&> >::difference_type to_first = 0
|
2012-06-22 10:14:21 +00:00
|
|
|
)
|
|
|
|
{
|
2013-02-26 07:14:04 +00:00
|
|
|
return sprout::sub_window(arr, to_first);
|
2012-06-22 10:14:21 +00:00
|
|
|
}
|
2013-02-26 07:14:04 +00:00
|
|
|
|
2012-06-22 10:14:21 +00:00
|
|
|
template<typename Container>
|
2012-10-05 15:58:56 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename std::enable_if<sprout::is_sub_array<Container>::value, Container>::type
|
|
|
|
sub(
|
2012-06-22 10:14:21 +00:00
|
|
|
Container const& arr,
|
|
|
|
typename sprout::container_traits<Container>::const_iterator first,
|
|
|
|
typename sprout::container_traits<Container>::const_iterator last
|
|
|
|
)
|
|
|
|
{
|
|
|
|
return Container(arr, first, last);
|
|
|
|
}
|
|
|
|
template<typename Container>
|
2012-10-05 15:58:56 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename std::enable_if<sprout::is_sub_array<Container>::value, Container>::type
|
|
|
|
sub(
|
2012-06-22 10:14:21 +00:00
|
|
|
Container const& arr,
|
|
|
|
typename sprout::container_traits<Container>::const_iterator first
|
|
|
|
)
|
|
|
|
{
|
|
|
|
return sprout::sub(arr, first, sprout::end(arr));
|
|
|
|
}
|
|
|
|
template<typename Container>
|
2012-10-05 15:58:56 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename std::enable_if<sprout::is_sub_array<Container>::value, Container>::type
|
|
|
|
sub(
|
2012-06-22 10:14:21 +00:00
|
|
|
Container const& arr,
|
2013-02-26 07:14:04 +00:00
|
|
|
typename sprout::container_traits<Container>::difference_type to_first,
|
|
|
|
typename sprout::container_traits<Container>::difference_type to_last
|
2012-06-22 10:14:21 +00:00
|
|
|
)
|
|
|
|
{
|
2013-02-26 07:14:04 +00:00
|
|
|
return sprout::sub_window(arr, to_first, to_last);
|
2012-06-22 10:14:21 +00:00
|
|
|
}
|
|
|
|
template<typename Container>
|
2012-10-05 15:58:56 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename std::enable_if<sprout::is_sub_array<Container>::value, Container>::type
|
|
|
|
sub(
|
2013-02-26 07:14:04 +00:00
|
|
|
Container const& arr,
|
|
|
|
typename sprout::container_traits<Container>::difference_type to_first = 0
|
2012-06-22 10:14:21 +00:00
|
|
|
)
|
|
|
|
{
|
2013-02-26 07:14:04 +00:00
|
|
|
return sprout::sub_window(arr, to_first);
|
2012-06-22 10:14:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// csub
|
|
|
|
//
|
|
|
|
template<typename Container>
|
2012-10-05 15:58:56 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename std::enable_if<!sprout::is_sub_array<Container>::value, sprout::sub_array<Container const&> >::type
|
|
|
|
csub(
|
2012-06-22 10:14:21 +00:00
|
|
|
Container const& arr,
|
|
|
|
typename sprout::container_traits<sprout::sub_array<Container const&> >::const_iterator first,
|
|
|
|
typename sprout::container_traits<sprout::sub_array<Container const&> >::const_iterator last
|
|
|
|
)
|
|
|
|
{
|
|
|
|
return sprout::sub_array<Container const&>(arr, first, last);
|
|
|
|
}
|
|
|
|
template<typename Container>
|
2012-10-05 15:58:56 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename std::enable_if<!sprout::is_sub_array<Container>::value, sprout::sub_array<Container const&> >::type
|
|
|
|
csub(
|
2012-06-22 10:14:21 +00:00
|
|
|
Container const& arr,
|
|
|
|
typename sprout::container_traits<sprout::sub_array<Container const&> >::const_iterator first
|
|
|
|
)
|
|
|
|
{
|
|
|
|
return sprout::csub(arr, first, sprout::end(arr));
|
|
|
|
}
|
|
|
|
template<typename Container>
|
2012-10-05 15:58:56 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename std::enable_if<!sprout::is_sub_array<Container>::value, sprout::sub_array<Container const&> >::type
|
|
|
|
csub(
|
2012-06-22 10:14:21 +00:00
|
|
|
Container const& arr,
|
2013-02-26 07:14:04 +00:00
|
|
|
typename sprout::container_traits<sprout::sub_array<Container const&> >::difference_type to_first,
|
|
|
|
typename sprout::container_traits<sprout::sub_array<Container const&> >::difference_type to_last
|
2012-06-22 10:14:21 +00:00
|
|
|
)
|
|
|
|
{
|
2013-02-26 07:14:04 +00:00
|
|
|
return sprout::csub_window(arr, to_first, to_last);
|
2012-06-22 10:14:21 +00:00
|
|
|
}
|
|
|
|
template<typename Container>
|
2012-10-05 15:58:56 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename std::enable_if<!sprout::is_sub_array<Container>::value, sprout::sub_array<Container const&> >::type
|
|
|
|
csub(
|
2013-02-26 07:14:04 +00:00
|
|
|
Container const& arr,
|
|
|
|
typename sprout::container_traits<sprout::sub_array<Container const&> >::difference_type to_first = 0
|
2012-06-22 10:14:21 +00:00
|
|
|
)
|
|
|
|
{
|
2013-02-26 07:14:04 +00:00
|
|
|
return sprout::csub_window(arr, to_first);
|
2012-06-22 10:14:21 +00:00
|
|
|
}
|
2013-02-26 07:14:04 +00:00
|
|
|
|
2012-06-22 10:14:21 +00:00
|
|
|
template<typename Container>
|
2012-10-05 15:58:56 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename std::enable_if<sprout::is_sub_array<Container>::value, sprout::sub_array<typename Container::internal_type const&> >::type
|
|
|
|
csub(
|
2012-06-22 10:14:21 +00:00
|
|
|
Container const& arr,
|
|
|
|
typename sprout::container_traits<Container>::const_iterator first,
|
|
|
|
typename sprout::container_traits<Container>::const_iterator last
|
|
|
|
)
|
|
|
|
{
|
|
|
|
return sprout::sub_array<typename Container::internal_type const&>(arr.get_array(), first, last);
|
|
|
|
}
|
|
|
|
template<typename Container>
|
2012-10-05 15:58:56 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename std::enable_if<sprout::is_sub_array<Container>::value, sprout::sub_array<typename Container::internal_type const&> >::type
|
|
|
|
csub(
|
2012-06-22 10:14:21 +00:00
|
|
|
Container const& arr,
|
|
|
|
typename sprout::container_traits<Container>::const_iterator first
|
|
|
|
)
|
|
|
|
{
|
|
|
|
return sprout::csub(arr, first, sprout::end(arr));
|
|
|
|
}
|
|
|
|
template<typename Container>
|
2012-10-05 15:58:56 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename std::enable_if<sprout::is_sub_array<Container>::value, sprout::sub_array<typename Container::internal_type const&> >::type
|
|
|
|
csub(
|
2012-06-22 10:14:21 +00:00
|
|
|
Container const& arr,
|
2013-02-26 07:14:04 +00:00
|
|
|
typename sprout::container_traits<Container>::difference_type to_first,
|
|
|
|
typename sprout::container_traits<Container>::difference_type to_last
|
2012-06-22 10:14:21 +00:00
|
|
|
)
|
|
|
|
{
|
2013-02-26 07:14:04 +00:00
|
|
|
return sprout::csub_window(arr, to_first, to_last);
|
2012-06-22 10:14:21 +00:00
|
|
|
}
|
|
|
|
template<typename Container>
|
2012-10-05 15:58:56 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename std::enable_if<sprout::is_sub_array<Container>::value, sprout::sub_array<typename Container::internal_type const&> >::type
|
|
|
|
csub(
|
2013-02-26 07:14:04 +00:00
|
|
|
Container const& arr,
|
|
|
|
typename sprout::container_traits<Container>::difference_type to_first = 0
|
2012-06-22 10:14:21 +00:00
|
|
|
)
|
|
|
|
{
|
2013-02-26 07:14:04 +00:00
|
|
|
return sprout::csub_window(arr, to_first);
|
2012-06-22 10:14:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// sub_copy
|
|
|
|
//
|
|
|
|
template<typename Container>
|
2012-10-05 15:58:56 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename std::enable_if<!sprout::is_sub_array<Container>::value, sprout::sub_array<Container> >::type
|
|
|
|
sub_copy(
|
2012-06-22 10:14:21 +00:00
|
|
|
Container const& arr,
|
|
|
|
typename sprout::container_traits<Container>::const_iterator first,
|
|
|
|
typename sprout::container_traits<Container>::const_iterator last
|
|
|
|
)
|
|
|
|
{
|
|
|
|
return sprout::sub_array<Container>(arr, first, last);
|
|
|
|
}
|
|
|
|
template<typename Container>
|
2012-10-05 15:58:56 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename std::enable_if<!sprout::is_sub_array<Container>::value, sprout::sub_array<Container> >::type
|
|
|
|
sub_copy(
|
2012-06-22 10:14:21 +00:00
|
|
|
Container const& arr,
|
|
|
|
typename sprout::container_traits<Container>::const_iterator first
|
|
|
|
)
|
|
|
|
{
|
|
|
|
return sprout::sub_copy(arr, first, sprout::end(arr));
|
|
|
|
}
|
|
|
|
template<typename Container>
|
2012-10-05 15:58:56 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename std::enable_if<!sprout::is_sub_array<Container>::value, sprout::sub_array<Container> >::type
|
|
|
|
sub_copy(
|
2012-06-22 10:14:21 +00:00
|
|
|
Container const& arr,
|
2013-02-26 07:14:04 +00:00
|
|
|
typename sprout::container_traits<Container>::difference_type to_first,
|
|
|
|
typename sprout::container_traits<Container>::difference_type to_last
|
2012-06-22 10:14:21 +00:00
|
|
|
)
|
|
|
|
{
|
2013-02-26 07:14:04 +00:00
|
|
|
return sprout::sub_window_copy(arr, to_first, to_last);
|
2012-06-22 10:14:21 +00:00
|
|
|
}
|
|
|
|
template<typename Container>
|
2012-10-05 15:58:56 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename std::enable_if<!sprout::is_sub_array<Container>::value, sprout::sub_array<Container> >::type
|
2013-02-26 07:14:04 +00:00
|
|
|
sub_copy(
|
|
|
|
Container const& arr,
|
|
|
|
typename sprout::container_traits<Container>::difference_type to_first = 0
|
2012-06-22 10:14:21 +00:00
|
|
|
)
|
|
|
|
{
|
2013-02-26 07:14:04 +00:00
|
|
|
return sprout::sub_window_copy(arr, to_first);
|
2012-06-22 10:14:21 +00:00
|
|
|
}
|
2013-02-26 07:14:04 +00:00
|
|
|
|
2012-06-22 10:14:21 +00:00
|
|
|
template<typename Container>
|
2012-10-05 15:58:56 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename std::enable_if<sprout::is_sub_array<Container>::value, sprout::sub_array<typename Container::internal_type> >::type
|
|
|
|
sub_copy(
|
2012-06-22 10:14:21 +00:00
|
|
|
Container const& arr,
|
|
|
|
typename sprout::container_traits<Container>::const_iterator first,
|
|
|
|
typename sprout::container_traits<Container>::const_iterator last
|
|
|
|
)
|
|
|
|
{
|
|
|
|
return sprout::sub_array<typename Container::internal_type>(arr.get_array(), first, last);
|
|
|
|
}
|
|
|
|
template<typename Container>
|
2012-10-05 15:58:56 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename std::enable_if<sprout::is_sub_array<Container>::value, sprout::sub_array<typename Container::internal_type> >::type
|
|
|
|
sub_copy(
|
2012-06-22 10:14:21 +00:00
|
|
|
Container const& arr,
|
|
|
|
typename sprout::container_traits<Container>::const_iterator first
|
|
|
|
)
|
|
|
|
{
|
|
|
|
return sprout::sub_copy(arr, first, sprout::end(arr));
|
|
|
|
}
|
|
|
|
template<typename Container>
|
2012-10-05 15:58:56 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename std::enable_if<sprout::is_sub_array<Container>::value, sprout::sub_array<typename Container::internal_type> >::type
|
|
|
|
sub_copy(
|
2012-06-22 10:14:21 +00:00
|
|
|
Container const& arr,
|
2013-02-26 07:14:04 +00:00
|
|
|
typename sprout::container_traits<Container>::difference_type to_first,
|
|
|
|
typename sprout::container_traits<Container>::difference_type to_last
|
2012-06-22 10:14:21 +00:00
|
|
|
)
|
|
|
|
{
|
2013-02-26 07:14:04 +00:00
|
|
|
return sprout::sub_window_copy(arr, to_first, to_last);
|
2012-06-22 10:14:21 +00:00
|
|
|
}
|
|
|
|
template<typename Container>
|
2012-10-05 15:58:56 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename std::enable_if<sprout::is_sub_array<Container>::value, sprout::sub_array<typename Container::internal_type> >::type
|
|
|
|
sub_copy(
|
2013-02-26 07:14:04 +00:00
|
|
|
Container const& arr,
|
|
|
|
typename sprout::container_traits<Container>::difference_type to_first = 0
|
2012-06-22 10:14:21 +00:00
|
|
|
)
|
|
|
|
{
|
2013-02-26 07:14:04 +00:00
|
|
|
return sprout::sub_window_copy(arr, to_first);
|
2012-06-22 10:14:21 +00:00
|
|
|
}
|
|
|
|
} // namespace sprout
|
|
|
|
|
|
|
|
#endif // #ifndef SPROUT_SUB_ARRAY_SUB_HPP
|