#ifndef SPROUT_ALGORITHM_STRING_JOIN_HPP #define SPROUT_ALGORITHM_STRING_JOIN_HPP #include #include #include #include #include #include namespace sprout { namespace algorithm { namespace result_of { // // join // template struct join { 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 join_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 join_impl_1( ContainerIterator first, ContainerIterator last, Separator const& separator, Container const& current ) { return sprout::algorithm::detail::join_impl_1( sprout::next(first), last, separator, sprout::fixed::append_back(sprout::fixed::append_back(current, separator), *first) ); } template SPROUT_CONSTEXPR inline Result join_impl( ContainerIterator first, ContainerIterator last, Separator const& separator ) { return first != last ? sprout::algorithm::detail::join_impl_1( sprout::next(first), last, separator, *first ) : sprout::make_clone() ; } } // namespace detail // // join // template SPROUT_CONSTEXPR inline typename sprout::algorithm::result_of::join::type join( ContainerContainer const& cont_cont, Separator const& separator ) { return sprout::algorithm::detail::join_impl::type>( sprout::begin(cont_cont), sprout::end(cont_cont), separator ); } } // namespace algorithm } // namespace sprout #endif // #ifndef SPROUT_ALGORITHM_STRING_JOIN_HPP