#ifndef SPROUT_ALGORITHM_STRING_JOIN_HPP #define SPROUT_ALGORITHM_STRING_JOIN_HPP #include #include #include #include #include #include #include namespace sprout { namespace algorithm { namespace result_of { // // join // template struct join { public: typedef typename sprout::container_transform_traits< typename sprout::container_traits::value_type >::template rebind_size< sprout::container_traits< typename sprout::container_traits::value_type >::static_size * sprout::container_traits::static_size >::type type; }; } // namespace result_of namespace detail { template inline SPROUT_CONSTEXPR typename std::enable_if< sprout::container_traits::static_size == sizeof...(Args), Result >::type join_impl( ContainerInputIterator first_cont, ContainerInputIterator last_cont, Args const&... args ); template inline SPROUT_CONSTEXPR typename std::enable_if< sprout::container_traits::static_size != sizeof...(Args), Result >::type join_impl( ContainerInputIterator first_cont, ContainerInputIterator last_cont, Args const&... args ); template inline SPROUT_CONSTEXPR typename std::enable_if< sprout::container_traits::static_size == sizeof...(Args), Result >::type join_impl_1( ContainerInputIterator first_cont, ContainerInputIterator last_cont, InputIterator first, InputIterator last, Args const&... args ) { return sprout::make(args...); } template inline SPROUT_CONSTEXPR typename std::enable_if< sprout::container_traits::static_size != sizeof...(Args), Result >::type join_impl_1( ContainerInputIterator first_cont, ContainerInputIterator last_cont, InputIterator first, InputIterator last, Args const&... args ) { return first != last ? sprout::algorithm::detail::join_impl_1(first_cont, last_cont, sprout::next(first), last, args..., *first) : sprout::algorithm::detail::join_impl(sprout::next(first_cont), last_cont, args...) ; } template inline SPROUT_CONSTEXPR typename std::enable_if< sprout::container_traits::static_size == sizeof...(Args), Result >::type join_impl( ContainerInputIterator first_cont, ContainerInputIterator last_cont, Args const&... args ) { return sprout::make(args...); } template inline SPROUT_CONSTEXPR typename std::enable_if< sprout::container_traits::static_size != sizeof...(Args), Result >::type join_impl( ContainerInputIterator first_cont, ContainerInputIterator last_cont, Args const&... args ) { return first_cont != last_cont ? sprout::algorithm::detail::join_impl_1(first_cont, last_cont, sprout::begin(*first_cont), sprout::end(*first_cont), args...) : sprout::make(args...) ; } } // namespace detail // // join // template inline SPROUT_CONSTEXPR typename sprout::algorithm::result_of::join::type join( ContainerContainer const& cont_cont ) { return sprout::algorithm::detail::join_impl::type>( sprout::begin(cont_cont), sprout::end(cont_cont) ); } } // namespace algorithm } // namespace sprout #endif // #ifndef SPROUT_ALGORITHM_STRING_JOIN_HPP