123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- #ifndef BOOST_MP_DETAIL_STRING_HELPERS_HPP
- #define BOOST_MP_DETAIL_STRING_HELPERS_HPP
- #include <algorithm>
- #include <cstring>
- namespace boost { namespace multiprecision { namespace detail {
- struct is_in_string
- {
- const char* begin;
- const char* end;
- is_in_string(const char* p) : begin(p), end(p + std::strlen(p)) {}
- bool operator()(char s) { return std::find(begin, end, s) != end; }
- };
- struct is_not_in_string
- {
- const char* begin;
- const char* end;
- is_not_in_string(const char* p) : begin(p), end(p + std::strlen(p)) {}
- bool operator()(char s) { return std::find(begin, end, s) == end; }
- };
- template <class Iterator>
- std::size_t find_first_of(Iterator begin, Iterator end, const char* what)
- {
- return static_cast<std::size_t>(std::find_if(begin, end, is_in_string(what)) - begin);
- }
- template <class Iterator>
- std::size_t find_first_not_of(Iterator begin, Iterator end, const char* what)
- {
- return static_cast<std::size_t>(std::find_if(begin, end, is_not_in_string(what)) - begin);
- }
- }}}
- #endif
|