#ifndef SPROUT_ALGORITHM_STRING_JOIN2_HPP #define SPROUT_ALGORITHM_STRING_JOIN2_HPP #include #include #include #include #include #include namespace sprout { namespace algorithm { namespace result_of { // // join2 // template struct join2 { public: typedef typename sprout::rebind_fixed_size< typename sprout::fixed_container_traits::value_type >::template apply< sprout::fixed_container_traits::fixed_size != 0 ? ( sprout::fixed_container_traits< typename sprout::fixed_container_traits::value_type >::fixed_size + (sprout::fixed_container_traits::fixed_size - 1) * ( sprout::fixed_container_traits::fixed_size + sprout::fixed_container_traits< typename sprout::fixed_container_traits::value_type >::fixed_size ) ) : 0 >::type type; }; } // namespace result_of namespace detail { template SPROUT_CONSTEXPR inline typename std::enable_if< (sprout::fixed_container_traits::fixed_size == sprout::fixed_container_traits::fixed_size), Result >::type join2_impl_1( ContainerIterator first, ContainerIterator last, Separator const& separator, Container const& current ) { return current; } template SPROUT_CONSTEXPR inline typename std::enable_if< (sprout::fixed_container_traits::fixed_size < sprout::fixed_container_traits::fixed_size), Result >::type join2_impl_1( ContainerIterator first, ContainerIterator last, Separator const& separator, Container const& current ) { return sprout::algorithm::detail::join2_impl_1( sprout::next(first), last, separator, sprout::fixed::append_back(sprout::fixed::append_back(current, separator), *first) ); } template SPROUT_CONSTEXPR inline Result join2_impl( ContainerIterator first, ContainerIterator last, Separator const& separator ) { return first != last ? sprout::algorithm::detail::join2_impl_1( sprout::next(first), last, separator, *first ) : sprout::make_clone() ; } } // namespace detail // // join2 // template SPROUT_CONSTEXPR inline typename sprout::algorithm::result_of::join2::type join2( ContainerContainer const& cont_cont, Separator const& separator ) { return sprout::algorithm::detail::join2_impl::type>( sprout::begin(cont_cont), sprout::end(cont_cont), separator ); } } // namespace algorithm } // namespace sprout #endif // #ifndef SPROUT_ALGORITHM_STRING_JOIN2_HPP