sprout/algorithm/fixed/partition_copy.hpp 修正

sprout/algorithm/fit/partition_copy.hpp 修正
This commit is contained in:
bolero-MURAKAMI 2011-10-27 11:24:47 +09:00
parent 4729d31bf2
commit 068656e0b7
11 changed files with 343 additions and 248 deletions

View file

@ -7,7 +7,9 @@
#include <sprout/algorithm/fixed/partition_copy.hpp>
#include <sprout/algorithm/fit/result_of.hpp>
#include <sprout/sub_array.hpp>
#include <sprout/detail/algorithm_ext.hpp>
#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT_DETAIL
#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT_DETAIL
namespace sprout {
namespace fit {
@ -24,7 +26,14 @@ namespace sprout {
return sprout::sub_copy(
sprout::get_fixed(sprout::fixed::partition_copy(first, last, result, pred)),
offset,
offset + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::min(NS_SSCRISK_CEL_OR_SPROUT_DETAIL::count_if(first, last, pred), sprout::size(result))
offset + sprout::detail::count_n_if(
first,
NS_SSCRISK_CEL_OR_SPROUT_DETAIL::min(
NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(first, last),
sprout::size(result)
),
pred
)
);
}
} // namespace detail

View file

@ -10,6 +10,7 @@
#include <sprout/fixed_container/functions.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/algorithm/fixed/result_of.hpp>
#include <sprout/detail/container_complate.hpp>
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL
namespace sprout {
@ -53,37 +54,15 @@ namespace sprout {
NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(first, last)
);
}
template<typename Result, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type copy_impl_3(
Result const& result,
Args const&... args
)
{
return sprout::remake_clone<Result, Result>(result, sprout::size(result), args...);
}
template<typename Result, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size != sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type copy_impl_3(
Result const& result,
Args const&... args
)
{
return copy_impl_3(result, args..., *sprout::next(sprout::fixed_begin(result), sizeof...(Args)));
}
template<typename InputIterator, typename Result, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type copy_impl_2(
>::type copy_impl(
InputIterator first,
InputIterator last,
Result const& result,
typename sprout::fixed_container_traits<Result>::difference_type offset,
typename sprout::fixed_container_traits<Result>::size_type size,
Args const&... args
)
{
@ -93,59 +72,19 @@ namespace sprout {
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size != sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type copy_impl_2(
>::type copy_impl(
InputIterator first,
InputIterator last,
Result const& result,
typename sprout::fixed_container_traits<Result>::difference_type offset,
typename sprout::fixed_container_traits<Result>::size_type size,
Args const&... args
)
{
return first != last && sizeof...(Args) < static_cast<std::size_t>(offset)
? copy_impl_2(sprout::next(first), last, result, offset, args..., *first)
: copy_impl_3(result, args...)
return first != last && sizeof...(Args) < size
? sprout::fixed::detail::copy_impl(sprout::next(first), last, result, size, args..., *first)
: sprout::detail::container_complate(result, args...)
;
}
template<typename InputIterator, typename Result, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type copy_impl_1(
InputIterator first,
InputIterator last,
Result const& result,
typename sprout::fixed_container_traits<Result>::difference_type offset,
Args const&... args
)
{
return sprout::remake_clone<Result, Result>(result, sprout::size(result), args...);
}
template<typename InputIterator, typename Result, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size != sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type copy_impl_1(
InputIterator first,
InputIterator last,
Result const& result,
typename sprout::fixed_container_traits<Result>::difference_type offset,
Args const&... args
)
{
return sizeof...(Args) < static_cast<std::size_t>(offset)
? copy_impl_1(first, last, result, offset, args..., *sprout::next(sprout::fixed_begin(result), sizeof...(Args)))
: copy_impl_2(first, last, result, offset + sprout::size(result), args...)
;
}
template<typename InputIterator, typename Result>
SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm<Result>::type copy_impl(
InputIterator first,
InputIterator last,
Result const& result
)
{
return copy_impl_1(first, last, result, sprout::fixed_begin_offset(result));
}
template<typename InputIterator, typename Result>
SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm<Result>::type copy(
InputIterator first,
@ -157,7 +96,8 @@ namespace sprout {
return sprout::fixed::detail::copy_impl(
first,
last,
result
result,
sprout::size(result)
);
}
} // namespace detail

View file

@ -10,6 +10,7 @@
#include <sprout/fixed_container/functions.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/algorithm/fixed/result_of.hpp>
#include <sprout/detail/container_complate_backward.hpp>
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL
namespace sprout {
@ -53,37 +54,15 @@ namespace sprout {
NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(first, last)
);
}
template<typename Result, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type copy_backward_impl_3(
Result const& result,
Args const&... args
)
{
return sprout::remake_clone<Result, Result>(result, sprout::size(result), args...);
}
template<typename Result, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size != sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type copy_backward_impl_3(
Result const& result,
Args const&... args
)
{
return copy_backward_impl_3(result, *sprout::prev(sprout::fixed_end(result), sizeof...(Args) + 1), args...);
}
template<typename BidirectionalIterator, typename Result, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type copy_backward_impl_2(
>::type copy_backward_impl(
BidirectionalIterator first,
BidirectionalIterator last,
Result const& result,
typename sprout::fixed_container_traits<Result>::difference_type offset,
typename sprout::fixed_container_traits<Result>::size_type size,
Args const&... args
)
{
@ -93,59 +72,19 @@ namespace sprout {
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size != sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type copy_backward_impl_2(
>::type copy_backward_impl(
BidirectionalIterator first,
BidirectionalIterator last,
Result const& result,
typename sprout::fixed_container_traits<Result>::difference_type offset,
typename sprout::fixed_container_traits<Result>::size_type size,
Args const&... args
)
{
return first != last && sizeof...(Args) < static_cast<std::size_t>(offset)
? copy_backward_impl_2(first, sprout::prev(last), result, offset, *sprout::prev(last), args...)
: copy_backward_impl_3(result, args...)
return first != last && sizeof...(Args) < size
? copy_backward_impl(first, sprout::prev(last), result, size, *sprout::prev(last), args...)
: sprout::detail::container_complate_backward(result, args...)
;
}
template<typename BidirectionalIterator, typename Result, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type copy_backward_impl_1(
BidirectionalIterator first,
BidirectionalIterator last,
Result const& result,
typename sprout::fixed_container_traits<Result>::difference_type offset,
Args const&... args
)
{
return sprout::remake_clone<Result, Result>(result, sprout::size(result), args...);
}
template<typename BidirectionalIterator, typename Result, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size != sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type copy_backward_impl_1(
BidirectionalIterator first,
BidirectionalIterator last,
Result const& result,
typename sprout::fixed_container_traits<Result>::difference_type offset,
Args const&... args
)
{
return sizeof...(Args) < static_cast<std::size_t>(offset)
? copy_backward_impl_1(first, last, result, offset, *sprout::prev(sprout::fixed_end(result), sizeof...(Args) + 1), args...)
: copy_backward_impl_2(first, last, result, offset + sprout::size(result), args...)
;
}
template<typename BidirectionalIterator, typename Result>
SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm<Result>::type copy_backward_impl(
BidirectionalIterator first,
BidirectionalIterator last,
Result const& result
)
{
return copy_backward_impl_1(first, last, result, sprout::fixed_end_offset(result));
}
template<typename BidirectionalIterator, typename Result>
SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm<Result>::type copy_backward(
BidirectionalIterator first,
@ -157,7 +96,8 @@ namespace sprout {
return sprout::fixed::detail::copy_backward_impl(
first,
last,
result
result,
sprout::size(result)
);
}
} // namespace detail

View file

@ -8,42 +8,21 @@
#include <sprout/fixed_container/functions.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/algorithm/fixed/result_of.hpp>
#include <sprout/detail/container_complate.hpp>
namespace sprout {
namespace fixed {
namespace detail {
template<typename Result, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type partition_copy_impl_3(
Result const& result,
Args const&... args
)
{
return sprout::remake_clone<Result, Result>(result, sprout::size(result), args...);
}
template<typename Result, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size != sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type partition_copy_impl_3(
Result const& result,
Args const&... args
)
{
return partition_copy_impl_3(result, args..., *sprout::next(sprout::fixed_begin(result), sizeof...(Args)));
}
template<typename InputIterator, typename Result, typename Predicate, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type partition_copy_impl_2(
>::type partition_copy_impl(
InputIterator first,
InputIterator last,
Result const& result,
Predicate pred,
typename sprout::fixed_container_traits<Result>::difference_type offset,
typename sprout::fixed_container_traits<Result>::size_type size,
Args const&... args
)
{
@ -53,65 +32,22 @@ namespace sprout {
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size != sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type partition_copy_impl_2(
>::type partition_copy_impl(
InputIterator first,
InputIterator last,
Result const& result,
Predicate pred,
typename sprout::fixed_container_traits<Result>::difference_type offset,
typename sprout::fixed_container_traits<Result>::size_type size,
Args const&... args
)
{
return first != last && sizeof...(Args) < static_cast<std::size_t>(offset)
return first != last && sizeof...(Args) < size
? pred(*first)
? partition_copy_impl_2(sprout::next(first), last, result, pred, offset, *first, args...)
: partition_copy_impl_2(sprout::next(first), last, result, pred, offset, args..., *first)
: partition_copy_impl_3(result, args...)
? sprout::fixed::detail::partition_copy_impl(sprout::next(first), last, result, pred, size, *first, args...)
: sprout::fixed::detail::partition_copy_impl(sprout::next(first), last, result, pred, size, args..., *first)
: sprout::detail::container_complate(result, args...)
;
}
template<typename InputIterator, typename Result, typename Predicate, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type partition_copy_impl_1(
InputIterator first,
InputIterator last,
Result const& result,
Predicate pred,
typename sprout::fixed_container_traits<Result>::difference_type offset,
Args const&... args
)
{
return sprout::remake_clone<Result, Result>(result, sprout::size(result), args...);
}
template<typename InputIterator, typename Result, typename Predicate, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size != sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type partition_copy_impl_1(
InputIterator first,
InputIterator last,
Result const& result,
Predicate pred,
typename sprout::fixed_container_traits<Result>::difference_type offset,
Args const&... args
)
{
return sizeof...(Args) < static_cast<std::size_t>(offset)
? partition_copy_impl_1(first, last, result, pred, offset, args..., *sprout::next(sprout::fixed_begin(result), sizeof...(Args)))
: partition_copy_impl_2(first, last, result, pred, offset + sprout::size(result), args...)
;
}
template<typename InputIterator, typename Result, typename Predicate>
SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm<Result>::type partition_copy_impl(
InputIterator first,
InputIterator last,
Result const& result,
Predicate pred
)
{
return partition_copy_impl_1(first, last, result, pred, sprout::fixed_begin_offset(result));
}
} // namespace detail
//
// partition_copy
@ -124,7 +60,13 @@ namespace sprout {
Predicate pred
)
{
return sprout::fixed::detail::partition_copy_impl(first, last, result, pred);
return sprout::fixed::detail::partition_copy_impl(
first,
last,
result,
pred,
sprout::size(result)
);
}
} // namespace fixed

View file

@ -34,11 +34,11 @@ namespace sprout {
//
// count
//
template<typename Iterator, typename T>
SPROUT_CONSTEXPR typename std::iterator_traits<Iterator>::difference_type count(
Iterator first,
Iterator last,
T const & value
template<typename InputIterator, typename T>
SPROUT_CONSTEXPR typename std::iterator_traits<InputIterator>::difference_type count(
InputIterator first,
InputIterator last,
T const& value
)
{
return first == last
@ -50,26 +50,27 @@ namespace sprout {
//
// count_if
//
template<typename Iterator, typename Predicate>
SPROUT_CONSTEXPR typename std::iterator_traits<Iterator>::difference_type count_if(
Iterator first,
Iterator last,
template<typename InputIterator, typename Predicate>
SPROUT_CONSTEXPR typename std::iterator_traits<InputIterator>::difference_type count_if(
InputIterator first,
InputIterator last,
Predicate pred
)
{
return first == last
? 0
: (pred(*first) ? 1 : 0) + sprout::detail::count_if(sprout::next(first), last, pred);
: (pred(*first) ? 1 : 0) + sprout::detail::count_if(sprout::next(first), last, pred)
;
}
//
// equal
//
template<typename Iterator1, typename Iterator2>
template<typename InputIterator1, typename InputIterator2>
SPROUT_CONSTEXPR bool equal(
Iterator1 first1,
Iterator1 last1,
Iterator2 first2
InputIterator1 first1,
InputIterator1 last1,
InputIterator2 first2
)
{
return first1 == last1
@ -77,28 +78,29 @@ namespace sprout {
: *first1 == *first2 && sprout::detail::equal(sprout::next(first1), last1, sprout::next(first2))
;
}
template<typename Iterator1, typename Iterator2, typename Predicate>
template<typename InputIterator1, typename InputIterator2, typename Predicate>
SPROUT_CONSTEXPR bool equal(
Iterator1 first1,
Iterator1 last1,
Iterator2 first2,
InputIterator1 first1,
InputIterator1 last1,
InputIterator2 first2,
Predicate pred
)
{
return first1 == last1
? true
: pred(*first1, *first2) && sprout::detail::equal(sprout::next(first1), last1, sprout::next(first2), pred);
: pred(*first1, *first2) && sprout::detail::equal(sprout::next(first1), last1, sprout::next(first2), pred)
;
}
//
// lexicographical_compare
//
template<typename Iterator1, typename Iterator2>
template<typename InputIterator1, typename InputIterator2>
SPROUT_CONSTEXPR bool lexicographical_compare(
Iterator1 first1,
Iterator1 last1,
Iterator2 first2,
Iterator2 last2
InputIterator1 first1,
InputIterator1 last1,
InputIterator2 first2,
InputIterator2 last2
)
{
return first2 == last2
@ -107,14 +109,15 @@ namespace sprout {
? true
: *first2 < *first1
? false
: sprout::detail::lexicographical_compare(sprout::next(first1), last1, sprout::next(first2), last2);
: sprout::detail::lexicographical_compare(sprout::next(first1), last1, sprout::next(first2), last2)
;
}
template<typename Iterator1, typename Iterator2, typename Compare>
template<typename InputIterator1, typename InputIterator2, typename Compare>
SPROUT_CONSTEXPR bool lexicographical_compare(
Iterator1 first1,
Iterator1 last1,
Iterator2 first2,
Iterator2 last2,
InputIterator1 first1,
InputIterator1 last1,
InputIterator2 first2,
InputIterator2 last2,
Compare comp
)
{
@ -124,14 +127,15 @@ namespace sprout {
? true
: comp(*first2, *first1)
? false
: sprout::detail::lexicographical_compare(sprout::next(first1), last1, sprout::next(first2), last2, comp);
: sprout::detail::lexicographical_compare(sprout::next(first1), last1, sprout::next(first2), last2, comp)
;
}
//
// find
//
template<typename Iterator, typename T>
SPROUT_CONSTEXPR Iterator find(Iterator first, Iterator last, T const& value) {
template<typename InputIterator, typename T>
SPROUT_CONSTEXPR InputIterator find(InputIterator first, InputIterator last, T const& value) {
return first == last || *first == value
? first
: sprout::detail::find(sprout::next(first), last, value)

View file

@ -0,0 +1,44 @@
#ifndef SPROUT_DETAIL_ALGORITHM_EXT_HPP
#define SPROUT_DETAIL_ALGORITHM_EXT_HPP
#include <iterator>
#include <sprout/config.hpp>
#include <sprout/iterator/operation.hpp>
namespace sprout {
namespace detail {
//
// count_n
//
template<typename InputIterator, typename Size, typename T>
SPROUT_CONSTEXPR typename std::iterator_traits<InputIterator>::difference_type count_n(
InputIterator first,
Size n,
T const& value
)
{
return n == 0
? 0
: (*first == value ? 1 : 0) + sprout::detail::count_n(sprout::next(first), n - 1, value)
;
}
//
// count_n_if
//
template<typename InputIterator, typename Size, typename Predicate>
SPROUT_CONSTEXPR typename std::iterator_traits<InputIterator>::difference_type count_n_if(
InputIterator first,
Size n,
Predicate pred
)
{
return n == 0
? 0
: (pred(*first) ? 1 : 0) + sprout::detail::count_n_if(sprout::next(first), n - 1, pred)
;
}
} // namespace detail
} // namespace sprout
#endif // #ifndef SPROUT_DETAIL_ALGORITHM_EXT_HPP

View file

@ -0,0 +1,87 @@
#ifndef SPROUT_DETAIL_CONTAINER_COMPLATE_HPP
#define SPROUT_DETAIL_CONTAINER_COMPLATE_HPP
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/fixed_container/traits.hpp>
#include <sprout/fixed_container/functions.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/algorithm/fixed/result_of.hpp>
namespace sprout {
namespace detail {
template<typename Result, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type container_complate_2(
Result const& result,
Args const&... args
)
{
return sprout::remake_clone<Result, Result>(result, sprout::size(result), args...);
}
template<typename Result, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size != sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type container_complate_2(
Result const& result,
Args const&... args
)
{
return container_complate_2(result, args..., *sprout::next(sprout::fixed_begin(result), sizeof...(Args)));
}
template<typename Result, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type container_complate_1(
Result const& result,
typename sprout::fixed_container_traits<Result>::difference_type remain,
Args const&... args
)
{
return sprout::remake_clone<Result, Result>(result, sprout::size(result), args...);
}
template<typename Result, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size != sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type container_complate_1(
Result const& result,
typename sprout::fixed_container_traits<Result>::difference_type remain,
Args const&... args
)
{
return remain != 0
? container_complate_1(result, remain - 1, *sprout::next(sprout::fixed_begin(result), remain - 1), args...)
: container_complate_2(result, args...)
;
}
template<typename Result, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type container_complate(
Result const& result,
Args const&... args
)
{
return sprout::remake_clone<Result, Result>(result, sprout::size(result), args...);
}
template<typename Result, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size != sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type container_complate(
Result const& result,
Args const&... args
)
{
return container_complate_1(result, sprout::fixed_begin_offset(result), args...);
}
} // namespace detail
} // namespace sprout
#endif // #ifndef SPROUT_DETAIL_CONTAINER_COMPLATE_HPP

View file

@ -0,0 +1,87 @@
#ifndef SPROUT_DETAIL_CONTAINER_COMPLATE_BACKWARD_HPP
#define SPROUT_DETAIL_CONTAINER_COMPLATE_BACKWARD_HPP
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/fixed_container/traits.hpp>
#include <sprout/fixed_container/functions.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/algorithm/fixed/result_of.hpp>
namespace sprout {
namespace detail {
template<typename Result, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type container_complate_backward_2(
Result const& result,
Args const&... args
)
{
return sprout::remake_clone<Result, Result>(result, sprout::size(result), args...);
}
template<typename Result, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size != sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type container_complate_backward_2(
Result const& result,
Args const&... args
)
{
return container_complate_backward_2(result, *sprout::prev(sprout::fixed_end(result), sizeof...(Args) + 1), args...);
}
template<typename Result, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type container_complate_backward_1(
Result const& result,
typename sprout::fixed_container_traits<Result>::difference_type remain,
Args const&... args
)
{
return sprout::remake_clone<Result, Result>(result, sprout::size(result), args...);
}
template<typename Result, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size != sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type container_complate_backward_1(
Result const& result,
typename sprout::fixed_container_traits<Result>::difference_type remain,
Args const&... args
)
{
return remain != 0
? container_complate_backward_1(result, remain - 1, args..., *sprout::prev(sprout::fixed_end(result), remain))
: container_complate_backward_2(result, args...)
;
}
template<typename Result, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type container_complate_backward(
Result const& result,
Args const&... args
)
{
return sprout::remake_clone<Result, Result>(result, sprout::size(result), args...);
}
template<typename Result, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size != sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type container_complate_backward(
Result const& result,
Args const&... args
)
{
return container_complate_backward_1(result, sprout::fixed_end_offset_backward(result), args...);
}
} // namespace detail
} // namespace sprout
#endif // #ifndef SPROUT_DETAIL_CONTAINER_COMPLATE_BACKWARD_HPP

View file

@ -0,0 +1,20 @@
#ifndef SPROUT_FIXED_CONTAINER_FIXED_BEGIN_OFFSET_BACKWARD_HPP
#define SPROUT_FIXED_CONTAINER_FIXED_BEGIN_OFFSET_BACKWARD_HPP
#include <sprout/config.hpp>
#include <sprout/fixed_container/traits.hpp>
#include <sprout/fixed_container/begin.hpp>
#include <sprout/fixed_container/fixed_end.hpp>
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL
namespace sprout {
//
// fixed_begin_offset_backward
//
template<typename Range>
SPROUT_CONSTEXPR typename sprout::fixed_container_traits<Range>::difference_type fixed_begin_offset_backward(Range const& range) {
return NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(sprout::begin(range), sprout::fixed_end(range));
}
} // namespace sprout
#endif // #ifndef SPROUT_FIXED_CONTAINER_FIXED_BEGIN_OFFSET_BACKWARD_HPP

View file

@ -0,0 +1,20 @@
#ifndef SPROUT_FIXED_CONTAINER_FIXED_END_OFFSET_BACKWARD_HPP
#define SPROUT_FIXED_CONTAINER_FIXED_END_OFFSET_BACKWARD_HPP
#include <sprout/config.hpp>
#include <sprout/fixed_container/traits.hpp>
#include <sprout/fixed_container/end.hpp>
#include <sprout/fixed_container/fixed_end.hpp>
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL
namespace sprout {
//
// fixed_end_offset_backward
//
template<typename Range>
SPROUT_CONSTEXPR typename sprout::fixed_container_traits<Range>::difference_type fixed_end_offset_backward(Range const& range) {
return NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(sprout::end(range), sprout::fixed_end(range));
}
} // namespace sprout
#endif // #ifndef SPROUT_FIXED_CONTAINER_FIXED_END_OFFSET_BACKWARD_HPP

View file

@ -10,6 +10,8 @@
#include <sprout/fixed_container/fixed_end.hpp>
#include <sprout/fixed_container/fixed_begin_offset.hpp>
#include <sprout/fixed_container/fixed_end_offset.hpp>
#include <sprout/fixed_container/fixed_begin_offset_backward.hpp>
#include <sprout/fixed_container/fixed_end_offset_backward.hpp>
#include <sprout/fixed_container/get_fixed.hpp>
#include <sprout/fixed_container/clone.hpp>
#include <sprout/fixed_container/make_clone.hpp>