/*============================================================================= Copyright (c) 2011-2019 Bolero MURAKAMI https://github.com/bolero-MURAKAMI/Sprout Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ #ifndef SPROUT_CSTRING_STRPBRK_HPP #define SPROUT_CSTRING_STRPBRK_HPP #include #include #include #include #include #include #include #include namespace sprout { namespace detail { template inline SPROUT_CONSTEXPR sprout::pair strpbrk_impl_1( sprout::pair current, ForwardIterator2 first2, typename std::iterator_traits::difference_type n ) { typedef sprout::pair type; return current.second || !*current.first ? current : n == 1 ? sprout::strchr(first2, *current.first) ? type(current.first, true) : type(sprout::next(current.first), false) : sprout::detail::strpbrk_impl_1( sprout::detail::strpbrk_impl_1( current, first2, n / 2 ), first2, n - n / 2 ) ; } template inline SPROUT_CONSTEXPR sprout::pair strpbrk_impl( sprout::pair current, ForwardIterator2 first2, typename std::iterator_traits::difference_type n ) { return current.second || !*current.first ? current : sprout::detail::strpbrk_impl( sprout::detail::strpbrk_impl_1( current, first2, n ), first2, n * 2 ) ; } template inline SPROUT_CONSTEXPR InputIterator1 strpbrk(InputIterator1 first1, ForwardIterator2 first2) { typedef sprout::pair type; return sprout::detail::strpbrk_impl(type(first1, false), first2, 1).first; } } // namespace detail // 7.21.5.4 strpbrk function // // recursion depth: // O(log(N1+N2)) // inline SPROUT_CONSTEXPR char const* strpbrk(char const* s1, char const* s2) { return sprout::detail::str_find_check( sprout::detail::strpbrk(s1, s2) ); } inline SPROUT_CONSTEXPR char* strpbrk(char* s1, char const* s2) { return sprout::detail::str_find_check( sprout::detail::strpbrk(s1, s2) ); } template inline SPROUT_CONSTEXPR typename std::enable_if< sprout::is_char_type::value, Elem* >::type strpbrk(Elem* s1, typename std::remove_const::type const* s2) { return sprout::detail::str_find_check( sprout::detail::strpbrk(s1, s2) ); } } // namespace sprout #endif // #ifndef SPROUT_CSTRING_STRPBRK_HPP