#ifndef SPROUT_ALGORITHM_FIXED_UNIQUE_COPY_HPP #define SPROUT_ALGORITHM_FIXED_UNIQUE_COPY_HPP #include #include #include #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) + 1, typename sprout::fixed::result_of::algorithm::type >::type unique_copy_impl( InputIterator first, InputIterator last, Result const& result, typename sprout::fixed_container_traits::size_type size, Head const& head, Args const&... args ) { return sprout::remake_clone(result, sprout::size(result), args..., head); } template SPROUT_CONSTEXPR inline typename std::enable_if< sprout::fixed_container_traits::fixed_size != sizeof...(Args) + 1, typename sprout::fixed::result_of::algorithm::type >::type unique_copy_impl( InputIterator first, InputIterator last, Result const& result, typename sprout::fixed_container_traits::size_type size, Head const& head, Args const&... args ) { return first != last && sizeof...(Args) + 1 < size ? !(head == *first) ? unique_copy_impl(sprout::next(first), last, result, size, *first, args..., head) : unique_copy_impl(sprout::next(first), last, result, size, head, args...) : sprout::detail::container_complate(result, args..., head) ; } } // namespace detail // // unique_copy // template SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type unique_copy( InputIterator first, InputIterator last, Result const& result ) { return first != last ? sprout::fixed::detail::unique_copy_impl(sprout::next(first), last, result, sprout::size(result), *first) : sprout::detail::container_complate(result) ; } namespace detail { template SPROUT_CONSTEXPR inline typename std::enable_if< sprout::fixed_container_traits::fixed_size == sizeof...(Args) + 1, typename sprout::fixed::result_of::algorithm::type >::type unique_copy_impl( InputIterator first, InputIterator last, Result const& result, BinaryPredicate pred, typename sprout::fixed_container_traits::size_type size, Head const& head, Args const&... args ) { return sprout::remake_clone(result, sprout::size(result), args..., head); } template SPROUT_CONSTEXPR inline typename std::enable_if< sprout::fixed_container_traits::fixed_size != sizeof...(Args) + 1, typename sprout::fixed::result_of::algorithm::type >::type unique_copy_impl( InputIterator first, InputIterator last, Result const& result, BinaryPredicate pred, typename sprout::fixed_container_traits::size_type size, Head const& head, Args const&... args ) { return first != last && sizeof...(Args) + 1 < size ? !pred(head, *first) ? sprout::fixed::detail::unique_copy_impl(sprout::next(first), last, result, pred, size, *first, args..., head) : sprout::fixed::detail::unique_copy_impl(sprout::next(first), last, result, pred, size, head, args...) : sprout::detail::container_complate(result, args..., head) ; } } // namespace detail // // unique_copy // template SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type unique_copy( InputIterator first, InputIterator last, Result const& result, BinaryPredicate pred ) { return first != last ? sprout::fixed::detail::unique_copy_impl(sprout::next(first), last, result, pred, sprout::size(result), *first) : sprout::detail::container_complate(result) ; } } // namespace fixed using sprout::fixed::unique_copy; } // namespace sprout #endif // #ifndef SPROUT_ALGORITHM_FIXED_UNIQUE_COPY_HPP