#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::container_transform_traits< typename sprout::container_traits::value_type >::template rebind_size< sprout::container_traits::static_size != 0 ? ( sprout::container_traits< typename sprout::container_traits::value_type >::static_size + (sprout::container_traits::static_size - 1) * ( sprout::container_traits::static_size + sprout::container_traits< typename sprout::container_traits::value_type >::static_size ) ) : 0 >::type type; }; } // namespace result_of namespace detail { template inline SPROUT_CONSTEXPR typename std::enable_if< (sprout::container_traits::static_size == sprout::container_traits::static_size), Result >::type join2_impl_1( ContainerIterator first, ContainerIterator last, Separator const& separator, Container const& current ) { return current; } template inline SPROUT_CONSTEXPR typename std::enable_if< (sprout::container_traits::static_size < sprout::container_traits::static_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 inline SPROUT_CONSTEXPR 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() ; } } // namespace detail // // join2 // template inline SPROUT_CONSTEXPR 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