diff --git a/sprout/algorithm/fit/partition_copy.hpp b/sprout/algorithm/fit/partition_copy.hpp index 86bf3026..bd4b9422 100644 --- a/sprout/algorithm/fit/partition_copy.hpp +++ b/sprout/algorithm/fit/partition_copy.hpp @@ -7,7 +7,9 @@ #include #include #include +#include #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 diff --git a/sprout/algorithm/fixed/copy.hpp b/sprout/algorithm/fixed/copy.hpp index 198ad235..77d8d6cc 100644 --- a/sprout/algorithm/fixed/copy.hpp +++ b/sprout/algorithm/fixed/copy.hpp @@ -10,6 +10,7 @@ #include #include #include +#include #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 - SPROUT_CONSTEXPR inline typename std::enable_if< - sprout::fixed_container_traits::fixed_size == sizeof...(Args), - typename sprout::fixed::result_of::algorithm::type - >::type copy_impl_3( - Result const& result, - Args const&... args - ) - { - return sprout::remake_clone(result, sprout::size(result), args...); - } - template - SPROUT_CONSTEXPR inline typename std::enable_if< - sprout::fixed_container_traits::fixed_size != sizeof...(Args), - typename sprout::fixed::result_of::algorithm::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 SPROUT_CONSTEXPR inline typename std::enable_if< sprout::fixed_container_traits::fixed_size == sizeof...(Args), typename sprout::fixed::result_of::algorithm::type - >::type copy_impl_2( + >::type copy_impl( InputIterator first, InputIterator last, Result const& result, - typename sprout::fixed_container_traits::difference_type offset, + typename sprout::fixed_container_traits::size_type size, Args const&... args ) { @@ -93,59 +72,19 @@ namespace sprout { SPROUT_CONSTEXPR inline typename std::enable_if< sprout::fixed_container_traits::fixed_size != sizeof...(Args), typename sprout::fixed::result_of::algorithm::type - >::type copy_impl_2( + >::type copy_impl( InputIterator first, InputIterator last, Result const& result, - typename sprout::fixed_container_traits::difference_type offset, + typename sprout::fixed_container_traits::size_type size, Args const&... args ) { - return first != last && sizeof...(Args) < static_cast(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 - SPROUT_CONSTEXPR inline typename std::enable_if< - sprout::fixed_container_traits::fixed_size == sizeof...(Args), - typename sprout::fixed::result_of::algorithm::type - >::type copy_impl_1( - InputIterator first, - InputIterator last, - Result const& result, - typename sprout::fixed_container_traits::difference_type offset, - Args const&... args - ) - { - return sprout::remake_clone(result, sprout::size(result), args...); - } - template - SPROUT_CONSTEXPR inline typename std::enable_if< - sprout::fixed_container_traits::fixed_size != sizeof...(Args), - typename sprout::fixed::result_of::algorithm::type - >::type copy_impl_1( - InputIterator first, - InputIterator last, - Result const& result, - typename sprout::fixed_container_traits::difference_type offset, - Args const&... args - ) - { - return sizeof...(Args) < static_cast(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 - SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type copy_impl( - InputIterator first, - InputIterator last, - Result const& result - ) - { - return copy_impl_1(first, last, result, sprout::fixed_begin_offset(result)); - } template SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::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 diff --git a/sprout/algorithm/fixed/copy_backward.hpp b/sprout/algorithm/fixed/copy_backward.hpp index 9f241386..33390019 100644 --- a/sprout/algorithm/fixed/copy_backward.hpp +++ b/sprout/algorithm/fixed/copy_backward.hpp @@ -10,6 +10,7 @@ #include #include #include +#include #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 - SPROUT_CONSTEXPR inline typename std::enable_if< - sprout::fixed_container_traits::fixed_size == sizeof...(Args), - typename sprout::fixed::result_of::algorithm::type - >::type copy_backward_impl_3( - Result const& result, - Args const&... args - ) - { - return sprout::remake_clone(result, sprout::size(result), args...); - } - template - SPROUT_CONSTEXPR inline typename std::enable_if< - sprout::fixed_container_traits::fixed_size != sizeof...(Args), - typename sprout::fixed::result_of::algorithm::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 SPROUT_CONSTEXPR inline typename std::enable_if< sprout::fixed_container_traits::fixed_size == sizeof...(Args), typename sprout::fixed::result_of::algorithm::type - >::type copy_backward_impl_2( + >::type copy_backward_impl( BidirectionalIterator first, BidirectionalIterator last, Result const& result, - typename sprout::fixed_container_traits::difference_type offset, + typename sprout::fixed_container_traits::size_type size, Args const&... args ) { @@ -93,59 +72,19 @@ namespace sprout { SPROUT_CONSTEXPR inline typename std::enable_if< sprout::fixed_container_traits::fixed_size != sizeof...(Args), typename sprout::fixed::result_of::algorithm::type - >::type copy_backward_impl_2( + >::type copy_backward_impl( BidirectionalIterator first, BidirectionalIterator last, Result const& result, - typename sprout::fixed_container_traits::difference_type offset, + typename sprout::fixed_container_traits::size_type size, Args const&... args ) { - return first != last && sizeof...(Args) < static_cast(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 - SPROUT_CONSTEXPR inline typename std::enable_if< - sprout::fixed_container_traits::fixed_size == sizeof...(Args), - typename sprout::fixed::result_of::algorithm::type - >::type copy_backward_impl_1( - BidirectionalIterator first, - BidirectionalIterator last, - Result const& result, - typename sprout::fixed_container_traits::difference_type offset, - Args const&... args - ) - { - return sprout::remake_clone(result, sprout::size(result), args...); - } - template - SPROUT_CONSTEXPR inline typename std::enable_if< - sprout::fixed_container_traits::fixed_size != sizeof...(Args), - typename sprout::fixed::result_of::algorithm::type - >::type copy_backward_impl_1( - BidirectionalIterator first, - BidirectionalIterator last, - Result const& result, - typename sprout::fixed_container_traits::difference_type offset, - Args const&... args - ) - { - return sizeof...(Args) < static_cast(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 - SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::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 SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::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 diff --git a/sprout/algorithm/fixed/partition_copy.hpp b/sprout/algorithm/fixed/partition_copy.hpp index 1a2b2c4f..c27f9e17 100644 --- a/sprout/algorithm/fixed/partition_copy.hpp +++ b/sprout/algorithm/fixed/partition_copy.hpp @@ -8,42 +8,21 @@ #include #include #include +#include namespace sprout { namespace fixed { namespace detail { - template - SPROUT_CONSTEXPR inline typename std::enable_if< - sprout::fixed_container_traits::fixed_size == sizeof...(Args), - typename sprout::fixed::result_of::algorithm::type - >::type partition_copy_impl_3( - Result const& result, - Args const&... args - ) - { - return sprout::remake_clone(result, sprout::size(result), args...); - } - template - SPROUT_CONSTEXPR inline typename std::enable_if< - sprout::fixed_container_traits::fixed_size != sizeof...(Args), - typename sprout::fixed::result_of::algorithm::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 SPROUT_CONSTEXPR inline typename std::enable_if< sprout::fixed_container_traits::fixed_size == sizeof...(Args), typename sprout::fixed::result_of::algorithm::type - >::type partition_copy_impl_2( + >::type partition_copy_impl( InputIterator first, InputIterator last, Result const& result, Predicate pred, - typename sprout::fixed_container_traits::difference_type offset, + typename sprout::fixed_container_traits::size_type size, Args const&... args ) { @@ -53,65 +32,22 @@ namespace sprout { SPROUT_CONSTEXPR inline typename std::enable_if< sprout::fixed_container_traits::fixed_size != sizeof...(Args), typename sprout::fixed::result_of::algorithm::type - >::type partition_copy_impl_2( + >::type partition_copy_impl( InputIterator first, InputIterator last, Result const& result, Predicate pred, - typename sprout::fixed_container_traits::difference_type offset, + typename sprout::fixed_container_traits::size_type size, Args const&... args ) { - return first != last && sizeof...(Args) < static_cast(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 - SPROUT_CONSTEXPR inline typename std::enable_if< - sprout::fixed_container_traits::fixed_size == sizeof...(Args), - typename sprout::fixed::result_of::algorithm::type - >::type partition_copy_impl_1( - InputIterator first, - InputIterator last, - Result const& result, - Predicate pred, - typename sprout::fixed_container_traits::difference_type offset, - Args const&... args - ) - { - return sprout::remake_clone(result, sprout::size(result), args...); - } - template - SPROUT_CONSTEXPR inline typename std::enable_if< - sprout::fixed_container_traits::fixed_size != sizeof...(Args), - typename sprout::fixed::result_of::algorithm::type - >::type partition_copy_impl_1( - InputIterator first, - InputIterator last, - Result const& result, - Predicate pred, - typename sprout::fixed_container_traits::difference_type offset, - Args const&... args - ) - { - return sizeof...(Args) < static_cast(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 - SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::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 diff --git a/sprout/detail/algorithm.hpp b/sprout/detail/algorithm.hpp index 5cffac09..a55d0c1b 100644 --- a/sprout/detail/algorithm.hpp +++ b/sprout/detail/algorithm.hpp @@ -34,11 +34,11 @@ namespace sprout { // // count // - template - SPROUT_CONSTEXPR typename std::iterator_traits::difference_type count( - Iterator first, - Iterator last, - T const & value + template + SPROUT_CONSTEXPR typename std::iterator_traits::difference_type count( + InputIterator first, + InputIterator last, + T const& value ) { return first == last @@ -50,26 +50,27 @@ namespace sprout { // // count_if // - template - SPROUT_CONSTEXPR typename std::iterator_traits::difference_type count_if( - Iterator first, - Iterator last, + template + SPROUT_CONSTEXPR typename std::iterator_traits::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 + template 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 + template 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 + template 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 + template 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 - SPROUT_CONSTEXPR Iterator find(Iterator first, Iterator last, T const& value) { + template + 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) diff --git a/sprout/detail/algorithm_ext.hpp b/sprout/detail/algorithm_ext.hpp new file mode 100644 index 00000000..58db22b1 --- /dev/null +++ b/sprout/detail/algorithm_ext.hpp @@ -0,0 +1,44 @@ +#ifndef SPROUT_DETAIL_ALGORITHM_EXT_HPP +#define SPROUT_DETAIL_ALGORITHM_EXT_HPP + +#include +#include +#include + +namespace sprout { + namespace detail { + // + // count_n + // + template + SPROUT_CONSTEXPR typename std::iterator_traits::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 + SPROUT_CONSTEXPR typename std::iterator_traits::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 diff --git a/sprout/detail/container_complate.hpp b/sprout/detail/container_complate.hpp new file mode 100644 index 00000000..d67b087e --- /dev/null +++ b/sprout/detail/container_complate.hpp @@ -0,0 +1,87 @@ +#ifndef SPROUT_DETAIL_CONTAINER_COMPLATE_HPP +#define SPROUT_DETAIL_CONTAINER_COMPLATE_HPP + +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace detail { + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size == sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type container_complate_2( + Result const& result, + Args const&... args + ) + { + return sprout::remake_clone(result, sprout::size(result), args...); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size != sizeof...(Args), + typename sprout::fixed::result_of::algorithm::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 + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size == sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type container_complate_1( + Result const& result, + typename sprout::fixed_container_traits::difference_type remain, + Args const&... args + ) + { + return sprout::remake_clone(result, sprout::size(result), args...); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size != sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type container_complate_1( + Result const& result, + typename sprout::fixed_container_traits::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 + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size == sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type container_complate( + Result const& result, + Args const&... args + ) + { + return sprout::remake_clone(result, sprout::size(result), args...); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size != sizeof...(Args), + typename sprout::fixed::result_of::algorithm::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 diff --git a/sprout/detail/container_complate_backward.hpp b/sprout/detail/container_complate_backward.hpp new file mode 100644 index 00000000..23174f1a --- /dev/null +++ b/sprout/detail/container_complate_backward.hpp @@ -0,0 +1,87 @@ +#ifndef SPROUT_DETAIL_CONTAINER_COMPLATE_BACKWARD_HPP +#define SPROUT_DETAIL_CONTAINER_COMPLATE_BACKWARD_HPP + +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace detail { + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size == sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type container_complate_backward_2( + Result const& result, + Args const&... args + ) + { + return sprout::remake_clone(result, sprout::size(result), args...); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size != sizeof...(Args), + typename sprout::fixed::result_of::algorithm::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 + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size == sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type container_complate_backward_1( + Result const& result, + typename sprout::fixed_container_traits::difference_type remain, + Args const&... args + ) + { + return sprout::remake_clone(result, sprout::size(result), args...); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size != sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type container_complate_backward_1( + Result const& result, + typename sprout::fixed_container_traits::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 + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size == sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type container_complate_backward( + Result const& result, + Args const&... args + ) + { + return sprout::remake_clone(result, sprout::size(result), args...); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size != sizeof...(Args), + typename sprout::fixed::result_of::algorithm::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 diff --git a/sprout/fixed_container/fixed_begin_offset_backward.hpp b/sprout/fixed_container/fixed_begin_offset_backward.hpp new file mode 100644 index 00000000..13181a50 --- /dev/null +++ b/sprout/fixed_container/fixed_begin_offset_backward.hpp @@ -0,0 +1,20 @@ +#ifndef SPROUT_FIXED_CONTAINER_FIXED_BEGIN_OFFSET_BACKWARD_HPP +#define SPROUT_FIXED_CONTAINER_FIXED_BEGIN_OFFSET_BACKWARD_HPP + +#include +#include +#include +#include +#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + // + // fixed_begin_offset_backward + // + template + SPROUT_CONSTEXPR typename sprout::fixed_container_traits::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 diff --git a/sprout/fixed_container/fixed_end_offset_backward.hpp b/sprout/fixed_container/fixed_end_offset_backward.hpp new file mode 100644 index 00000000..de7a301f --- /dev/null +++ b/sprout/fixed_container/fixed_end_offset_backward.hpp @@ -0,0 +1,20 @@ +#ifndef SPROUT_FIXED_CONTAINER_FIXED_END_OFFSET_BACKWARD_HPP +#define SPROUT_FIXED_CONTAINER_FIXED_END_OFFSET_BACKWARD_HPP + +#include +#include +#include +#include +#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + // + // fixed_end_offset_backward + // + template + SPROUT_CONSTEXPR typename sprout::fixed_container_traits::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 diff --git a/sprout/fixed_container/functions.hpp b/sprout/fixed_container/functions.hpp index 40d4e42a..1311ceec 100644 --- a/sprout/fixed_container/functions.hpp +++ b/sprout/fixed_container/functions.hpp @@ -10,6 +10,8 @@ #include #include #include +#include +#include #include #include #include