diff --git a/include/boost/regex/concepts.hpp b/include/boost/regex/concepts.hpp index 276e63f7..fe14f400 100644 --- a/include/boost/regex/concepts.hpp +++ b/include/boost/regex/concepts.hpp @@ -31,6 +31,12 @@ #include #include +#ifdef BOOST_REGEX_CXX03 +#define RW_NS boost +#else +#define RW_NS std +#endif + namespace boost{ // @@ -996,37 +1002,36 @@ struct BoostRegexConcept out = regex_format(out, m_cresults, func2b); out = regex_format(out, m_cresults, func1b, f); out = regex_format(out, m_cresults, func1b); - out = regex_format(out, m_cresults, boost::ref(func3b), f); - out = regex_format(out, m_cresults, boost::ref(func3b)); - out = regex_format(out, m_cresults, boost::ref(func2b), f); - out = regex_format(out, m_cresults, boost::ref(func2b)); - out = regex_format(out, m_cresults, boost::ref(func1b), f); - out = regex_format(out, m_cresults, boost::ref(func1b)); - out = regex_format(out, m_cresults, boost::cref(func3b), f); - out = regex_format(out, m_cresults, boost::cref(func3b)); - out = regex_format(out, m_cresults, boost::cref(func2b), f); - out = regex_format(out, m_cresults, boost::cref(func2b)); - out = regex_format(out, m_cresults, boost::cref(func1b), f); - out = regex_format(out, m_cresults, boost::cref(func1b)); - + out = regex_format(out, m_cresults, RW_NS::ref(func3b), f); + out = regex_format(out, m_cresults, RW_NS::ref(func3b)); + out = regex_format(out, m_cresults, RW_NS::ref(func2b), f); + out = regex_format(out, m_cresults, RW_NS::ref(func2b)); + out = regex_format(out, m_cresults, RW_NS::ref(func1b), f); + out = regex_format(out, m_cresults, RW_NS::ref(func1b)); + out = regex_format(out, m_cresults, RW_NS::cref(func3b), f); + out = regex_format(out, m_cresults, RW_NS::cref(func3b)); + out = regex_format(out, m_cresults, RW_NS::cref(func2b), f); + out = regex_format(out, m_cresults, RW_NS::cref(func2b)); + out = regex_format(out, m_cresults, RW_NS::cref(func1b), f); + out = regex_format(out, m_cresults, RW_NS::cref(func1b)); m_string += regex_format(m_cresults, func3b, f); m_string += regex_format(m_cresults, func3b); m_string += regex_format(m_cresults, func2b, f); m_string += regex_format(m_cresults, func2b); m_string += regex_format(m_cresults, func1b, f); m_string += regex_format(m_cresults, func1b); - m_string += regex_format(m_cresults, boost::ref(func3b), f); - m_string += regex_format(m_cresults, boost::ref(func3b)); - m_string += regex_format(m_cresults, boost::ref(func2b), f); - m_string += regex_format(m_cresults, boost::ref(func2b)); - m_string += regex_format(m_cresults, boost::ref(func1b), f); - m_string += regex_format(m_cresults, boost::ref(func1b)); - m_string += regex_format(m_cresults, boost::cref(func3b), f); - m_string += regex_format(m_cresults, boost::cref(func3b)); - m_string += regex_format(m_cresults, boost::cref(func2b), f); - m_string += regex_format(m_cresults, boost::cref(func2b)); - m_string += regex_format(m_cresults, boost::cref(func1b), f); - m_string += regex_format(m_cresults, boost::cref(func1b)); + m_string += regex_format(m_cresults, RW_NS::ref(func3b), f); + m_string += regex_format(m_cresults, RW_NS::ref(func3b)); + m_string += regex_format(m_cresults, RW_NS::ref(func2b), f); + m_string += regex_format(m_cresults, RW_NS::ref(func2b)); + m_string += regex_format(m_cresults, RW_NS::ref(func1b), f); + m_string += regex_format(m_cresults, RW_NS::ref(func1b)); + m_string += regex_format(m_cresults, RW_NS::cref(func3b), f); + m_string += regex_format(m_cresults, RW_NS::cref(func3b)); + m_string += regex_format(m_cresults, RW_NS::cref(func2b), f); + m_string += regex_format(m_cresults, RW_NS::cref(func2b)); + m_string += regex_format(m_cresults, RW_NS::cref(func1b), f); + m_string += regex_format(m_cresults, RW_NS::cref(func1b)); out = m_cresults.format(out, func3b, f); out = m_cresults.format(out, func3b); @@ -1034,18 +1039,18 @@ struct BoostRegexConcept out = m_cresults.format(out, func2b); out = m_cresults.format(out, func1b, f); out = m_cresults.format(out, func1b); - out = m_cresults.format(out, boost::ref(func3b), f); - out = m_cresults.format(out, boost::ref(func3b)); - out = m_cresults.format(out, boost::ref(func2b), f); - out = m_cresults.format(out, boost::ref(func2b)); - out = m_cresults.format(out, boost::ref(func1b), f); - out = m_cresults.format(out, boost::ref(func1b)); - out = m_cresults.format(out, boost::cref(func3b), f); - out = m_cresults.format(out, boost::cref(func3b)); - out = m_cresults.format(out, boost::cref(func2b), f); - out = m_cresults.format(out, boost::cref(func2b)); - out = m_cresults.format(out, boost::cref(func1b), f); - out = m_cresults.format(out, boost::cref(func1b)); + out = m_cresults.format(out, RW_NS::ref(func3b), f); + out = m_cresults.format(out, RW_NS::ref(func3b)); + out = m_cresults.format(out, RW_NS::ref(func2b), f); + out = m_cresults.format(out, RW_NS::ref(func2b)); + out = m_cresults.format(out, RW_NS::ref(func1b), f); + out = m_cresults.format(out, RW_NS::ref(func1b)); + out = m_cresults.format(out, RW_NS::cref(func3b), f); + out = m_cresults.format(out, RW_NS::cref(func3b)); + out = m_cresults.format(out, RW_NS::cref(func2b), f); + out = m_cresults.format(out, RW_NS::cref(func2b)); + out = m_cresults.format(out, RW_NS::cref(func1b), f); + out = m_cresults.format(out, RW_NS::cref(func1b)); m_string += m_cresults.format(func3b, f); m_string += m_cresults.format(func3b); @@ -1053,18 +1058,18 @@ struct BoostRegexConcept m_string += m_cresults.format(func2b); m_string += m_cresults.format(func1b, f); m_string += m_cresults.format(func1b); - m_string += m_cresults.format(boost::ref(func3b), f); - m_string += m_cresults.format(boost::ref(func3b)); - m_string += m_cresults.format(boost::ref(func2b), f); - m_string += m_cresults.format(boost::ref(func2b)); - m_string += m_cresults.format(boost::ref(func1b), f); - m_string += m_cresults.format(boost::ref(func1b)); - m_string += m_cresults.format(boost::cref(func3b), f); - m_string += m_cresults.format(boost::cref(func3b)); - m_string += m_cresults.format(boost::cref(func2b), f); - m_string += m_cresults.format(boost::cref(func2b)); - m_string += m_cresults.format(boost::cref(func1b), f); - m_string += m_cresults.format(boost::cref(func1b)); + m_string += m_cresults.format(RW_NS::ref(func3b), f); + m_string += m_cresults.format(RW_NS::ref(func3b)); + m_string += m_cresults.format(RW_NS::ref(func2b), f); + m_string += m_cresults.format(RW_NS::ref(func2b)); + m_string += m_cresults.format(RW_NS::ref(func1b), f); + m_string += m_cresults.format(RW_NS::ref(func1b)); + m_string += m_cresults.format(RW_NS::cref(func3b), f); + m_string += m_cresults.format(RW_NS::cref(func3b)); + m_string += m_cresults.format(RW_NS::cref(func2b), f); + m_string += m_cresults.format(RW_NS::cref(func2b)); + m_string += m_cresults.format(RW_NS::cref(func1b), f); + m_string += m_cresults.format(RW_NS::cref(func1b)); out = regex_replace(out, m_in, m_in, ce, func3, f); out = regex_replace(out, m_in, m_in, ce, func3); @@ -1072,18 +1077,18 @@ struct BoostRegexConcept out = regex_replace(out, m_in, m_in, ce, func2); out = regex_replace(out, m_in, m_in, ce, func1, f); out = regex_replace(out, m_in, m_in, ce, func1); - out = regex_replace(out, m_in, m_in, ce, boost::ref(func3), f); - out = regex_replace(out, m_in, m_in, ce, boost::ref(func3)); - out = regex_replace(out, m_in, m_in, ce, boost::ref(func2), f); - out = regex_replace(out, m_in, m_in, ce, boost::ref(func2)); - out = regex_replace(out, m_in, m_in, ce, boost::ref(func1), f); - out = regex_replace(out, m_in, m_in, ce, boost::ref(func1)); - out = regex_replace(out, m_in, m_in, ce, boost::cref(func3), f); - out = regex_replace(out, m_in, m_in, ce, boost::cref(func3)); - out = regex_replace(out, m_in, m_in, ce, boost::cref(func2), f); - out = regex_replace(out, m_in, m_in, ce, boost::cref(func2)); - out = regex_replace(out, m_in, m_in, ce, boost::cref(func1), f); - out = regex_replace(out, m_in, m_in, ce, boost::cref(func1)); + out = regex_replace(out, m_in, m_in, ce, RW_NS::ref(func3), f); + out = regex_replace(out, m_in, m_in, ce, RW_NS::ref(func3)); + out = regex_replace(out, m_in, m_in, ce, RW_NS::ref(func2), f); + out = regex_replace(out, m_in, m_in, ce, RW_NS::ref(func2)); + out = regex_replace(out, m_in, m_in, ce, RW_NS::ref(func1), f); + out = regex_replace(out, m_in, m_in, ce, RW_NS::ref(func1)); + out = regex_replace(out, m_in, m_in, ce, RW_NS::cref(func3), f); + out = regex_replace(out, m_in, m_in, ce, RW_NS::cref(func3)); + out = regex_replace(out, m_in, m_in, ce, RW_NS::cref(func2), f); + out = regex_replace(out, m_in, m_in, ce, RW_NS::cref(func2)); + out = regex_replace(out, m_in, m_in, ce, RW_NS::cref(func1), f); + out = regex_replace(out, m_in, m_in, ce, RW_NS::cref(func1)); functor3 > func3s; functor2 > func2s; @@ -1094,18 +1099,18 @@ struct BoostRegexConcept m_string += regex_replace(m_string, ce, func2s); m_string += regex_replace(m_string, ce, func1s, f); m_string += regex_replace(m_string, ce, func1s); - m_string += regex_replace(m_string, ce, boost::ref(func3s), f); - m_string += regex_replace(m_string, ce, boost::ref(func3s)); - m_string += regex_replace(m_string, ce, boost::ref(func2s), f); - m_string += regex_replace(m_string, ce, boost::ref(func2s)); - m_string += regex_replace(m_string, ce, boost::ref(func1s), f); - m_string += regex_replace(m_string, ce, boost::ref(func1s)); - m_string += regex_replace(m_string, ce, boost::cref(func3s), f); - m_string += regex_replace(m_string, ce, boost::cref(func3s)); - m_string += regex_replace(m_string, ce, boost::cref(func2s), f); - m_string += regex_replace(m_string, ce, boost::cref(func2s)); - m_string += regex_replace(m_string, ce, boost::cref(func1s), f); - m_string += regex_replace(m_string, ce, boost::cref(func1s)); + m_string += regex_replace(m_string, ce, RW_NS::ref(func3s), f); + m_string += regex_replace(m_string, ce, RW_NS::ref(func3s)); + m_string += regex_replace(m_string, ce, RW_NS::ref(func2s), f); + m_string += regex_replace(m_string, ce, RW_NS::ref(func2s)); + m_string += regex_replace(m_string, ce, RW_NS::ref(func1s), f); + m_string += regex_replace(m_string, ce, RW_NS::ref(func1s)); + m_string += regex_replace(m_string, ce, RW_NS::cref(func3s), f); + m_string += regex_replace(m_string, ce, RW_NS::cref(func3s)); + m_string += regex_replace(m_string, ce, RW_NS::cref(func2s), f); + m_string += regex_replace(m_string, ce, RW_NS::cref(func2s)); + m_string += regex_replace(m_string, ce, RW_NS::cref(func1s), f); + m_string += regex_replace(m_string, ce, RW_NS::cref(func1s)); } std::basic_ostream m_stream; diff --git a/include/boost/regex/config.hpp b/include/boost/regex/config.hpp index 5d58b733..eae56d41 100644 --- a/include/boost/regex/config.hpp +++ b/include/boost/regex/config.hpp @@ -44,6 +44,20 @@ #include #endif +/************************************************************************* +* +* Asserts: +* +*************************************************************************/ + +#ifdef BOOST_REGEX_STANDALONE +#include +# define BOOST_REGEX_ASSERT(x) assert(x) +#else +#include +# define BOOST_REGEX_ASSERT(x) BOOST_ASSERT(x) +#endif + /***************************************************************************** * * Include all the headers we need here: diff --git a/include/boost/regex/icu.hpp b/include/boost/regex/icu.hpp index 44f53419..2d7121cd 100644 --- a/include/boost/regex/icu.hpp +++ b/include/boost/regex/icu.hpp @@ -27,7 +27,7 @@ #include #include #include -#include +#include #ifdef BOOST_MSVC #pragma warning (push) @@ -73,19 +73,19 @@ public: typedef u32_to_u16_iterator itt; itt i(p1), j(p2); std::vector< ::UChar> t(i, j); - ::uint8_t result[100]; - ::int32_t len; + std::uint8_t result[100]; + std::int32_t len; if (!t.empty()) - len = pcoll->getSortKey(&*t.begin(), static_cast<::int32_t>(t.size()), result, sizeof(result)); + len = pcoll->getSortKey(&*t.begin(), static_cast(t.size()), result, sizeof(result)); else - len = pcoll->getSortKey(static_cast(0), static_cast<::int32_t>(0), result, sizeof(result)); + len = pcoll->getSortKey(static_cast(0), static_cast(0), result, sizeof(result)); if (std::size_t(len) > sizeof(result)) { - scoped_array< ::uint8_t> presult(new ::uint8_t[len + 1]); + std::unique_ptr< std::uint8_t[]> presult(new ::uint8_t[len + 1]); if (!t.empty()) - len = pcoll->getSortKey(&*t.begin(), static_cast<::int32_t>(t.size()), presult.get(), len + 1); + len = pcoll->getSortKey(&*t.begin(), static_cast(t.size()), presult.get(), len + 1); else - len = pcoll->getSortKey(static_cast(0), static_cast<::int32_t>(0), presult.get(), len + 1); + len = pcoll->getSortKey(static_cast(0), static_cast(0), presult.get(), len + 1); if ((0 == presult[len - 1]) && (len > 1)) --len; return string_type(presult.get(), presult.get() + len); @@ -109,14 +109,20 @@ private: boost::throw_exception(e); } U_NAMESPACE_QUALIFIER Locale m_locale; // The ICU locale that we're using - boost::scoped_ptr< U_NAMESPACE_QUALIFIER Collator> m_collator; // The full collation object - boost::scoped_ptr< U_NAMESPACE_QUALIFIER Collator> m_primary_collator; // The primary collation object + std::unique_ptr< U_NAMESPACE_QUALIFIER Collator> m_collator; // The full collation object + std::unique_ptr< U_NAMESPACE_QUALIFIER Collator> m_primary_collator; // The primary collation object }; - +#ifdef BOOST_REGEX_CXX03 inline boost::shared_ptr get_icu_regex_traits_implementation(const U_NAMESPACE_QUALIFIER Locale& loc) { return boost::shared_ptr(new icu_regex_traits_implementation(loc)); } +#else +inline std::shared_ptr get_icu_regex_traits_implementation(const U_NAMESPACE_QUALIFIER Locale& loc) +{ + return std::shared_ptr(new icu_regex_traits_implementation(loc)); +} +#endif } @@ -251,17 +257,13 @@ public: if (result != 0) return result; } - BOOST_ASSERT(std::size_t(idx + 1) < sizeof(masks) / sizeof(masks[0])); + BOOST_REGEX_ASSERT(std::size_t(idx + 1) < sizeof(masks) / sizeof(masks[0])); return masks[idx + 1]; } string_type lookup_collatename(const char_type* p1, const char_type* p2) const { string_type result; -#ifdef BOOST_NO_CXX98_BINDERS if (std::find_if(p1, p2, std::bind(std::greater< ::UChar32>(), std::placeholders::_1, 0x7f)) == p2) -#else - if (std::find_if(p1, p2, std::bind2nd(std::greater< ::UChar32>(), 0x7f)) == p2) -#endif { std::string s(p1, p2); // Try Unicode name: @@ -331,7 +333,7 @@ public: } int value(char_type c, int radix)const { - return u_digit(c, static_cast< ::int8_t>(radix)); + return u_digit(c, static_cast< std::int8_t>(radix)); } locale_type imbue(locale_type l) { @@ -631,8 +633,11 @@ private: return icu_class_map[p - ranges_begin]; return 0; } - +#ifdef BOOST_REGEX_CXX03 boost::shared_ptr< ::boost::BOOST_REGEX_DETAIL_NS::icu_regex_traits_implementation> m_pimpl; +#else + std::shared_ptr< ::boost::BOOST_REGEX_DETAIL_NS::icu_regex_traits_implementation> m_pimpl; +#endif }; } // namespace boost @@ -653,7 +658,7 @@ template inline u32regex do_make_u32regex(InputIterator i, InputIterator j, boost::regex_constants::syntax_option_type opt, - const boost::mpl::int_<1>*) + const std::integral_constant*) { typedef boost::u8_to_u32_iterator conv_type; return u32regex(conv_type(i, i, j), conv_type(j, i, j), opt); @@ -663,7 +668,7 @@ template inline u32regex do_make_u32regex(InputIterator i, InputIterator j, boost::regex_constants::syntax_option_type opt, - const boost::mpl::int_<2>*) + const std::integral_constant*) { typedef boost::u16_to_u32_iterator conv_type; return u32regex(conv_type(i, i, j), conv_type(j, i, j), opt); @@ -673,7 +678,7 @@ template inline u32regex do_make_u32regex(InputIterator i, InputIterator j, boost::regex_constants::syntax_option_type opt, - const boost::mpl::int_<4>*) + const std::integral_constant*) { return u32regex(i, j, opt); } @@ -715,18 +720,18 @@ inline u32regex make_u32regex(InputIterator i, InputIterator j, boost::regex_constants::syntax_option_type opt) { - return BOOST_REGEX_DETAIL_NS::do_make_u32regex(i, j, opt, static_cast const*>(0)); + return BOOST_REGEX_DETAIL_NS::do_make_u32regex(i, j, opt, static_cast const*>(0)); } // // construction from UTF-8 nul-terminated strings: // inline u32regex make_u32regex(const char* p, boost::regex_constants::syntax_option_type opt = boost::regex_constants::perl) { - return BOOST_REGEX_DETAIL_NS::do_make_u32regex(p, p + std::strlen(p), opt, static_cast const*>(0)); + return BOOST_REGEX_DETAIL_NS::do_make_u32regex(p, p + std::strlen(p), opt, static_cast const*>(0)); } inline u32regex make_u32regex(const unsigned char* p, boost::regex_constants::syntax_option_type opt = boost::regex_constants::perl) { - return BOOST_REGEX_DETAIL_NS::do_make_u32regex(p, p + std::strlen(reinterpret_cast(p)), opt, static_cast const*>(0)); + return BOOST_REGEX_DETAIL_NS::do_make_u32regex(p, p + std::strlen(reinterpret_cast(p)), opt, static_cast const*>(0)); } // // construction from UTF-16 nul-terminated strings: @@ -734,13 +739,13 @@ inline u32regex make_u32regex(const unsigned char* p, boost::regex_constants::sy #ifndef BOOST_NO_WREGEX inline u32regex make_u32regex(const wchar_t* p, boost::regex_constants::syntax_option_type opt = boost::regex_constants::perl) { - return BOOST_REGEX_DETAIL_NS::do_make_u32regex(p, p + std::wcslen(p), opt, static_cast const*>(0)); + return BOOST_REGEX_DETAIL_NS::do_make_u32regex(p, p + std::wcslen(p), opt, static_cast const*>(0)); } #endif #if !BOOST_REGEX_UCHAR_IS_WCHAR_T inline u32regex make_u32regex(const UChar* p, boost::regex_constants::syntax_option_type opt = boost::regex_constants::perl) { - return BOOST_REGEX_DETAIL_NS::do_make_u32regex(p, p + u_strlen(p), opt, static_cast const*>(0)); + return BOOST_REGEX_DETAIL_NS::do_make_u32regex(p, p + u_strlen(p), opt, static_cast const*>(0)); } #endif // @@ -749,14 +754,14 @@ inline u32regex make_u32regex(const UChar* p, boost::regex_constants::syntax_opt template inline u32regex make_u32regex(const std::basic_string& s, boost::regex_constants::syntax_option_type opt = boost::regex_constants::perl) { - return BOOST_REGEX_DETAIL_NS::do_make_u32regex(s.begin(), s.end(), opt, static_cast const*>(0)); + return BOOST_REGEX_DETAIL_NS::do_make_u32regex(s.begin(), s.end(), opt, static_cast const*>(0)); } // // Construction from ICU string type: // inline u32regex make_u32regex(const U_NAMESPACE_QUALIFIER UnicodeString& s, boost::regex_constants::syntax_option_type opt = boost::regex_constants::perl) { - return BOOST_REGEX_DETAIL_NS::do_make_u32regex(s.getBuffer(), s.getBuffer() + s.length(), opt, static_cast const*>(0)); + return BOOST_REGEX_DETAIL_NS::do_make_u32regex(s.getBuffer(), s.getBuffer() + s.length(), opt, static_cast const*>(0)); } // @@ -1222,7 +1227,7 @@ OutputIterator do_regex_replace(OutputIterator out, if(i == j) { if(!(flags & regex_constants::format_no_copy)) - out = BOOST_REGEX_DETAIL_NS::copy(in.first, in.second, out); + out = std::copy(in.first, in.second, out); } else { @@ -1230,7 +1235,7 @@ OutputIterator do_regex_replace(OutputIterator out, while(i != j) { if(!(flags & regex_constants::format_no_copy)) - out = BOOST_REGEX_DETAIL_NS::copy(i->prefix().first, i->prefix().second, out); + out = std::copy(i->prefix().first, i->prefix().second, out); if(!f.empty()) out = ::boost::BOOST_REGEX_DETAIL_NS::regex_format_imp(out, *i, &*f.begin(), &*f.begin() + f.size(), flags, e.get_traits()); else @@ -1241,7 +1246,7 @@ OutputIterator do_regex_replace(OutputIterator out, ++i; } if(!(flags & regex_constants::format_no_copy)) - out = BOOST_REGEX_DETAIL_NS::copy(last_m, in.second, out); + out = std::copy(last_m, in.second, out); } return out; } diff --git a/include/boost/regex/pending/object_cache.hpp b/include/boost/regex/pending/object_cache.hpp index ea51ba3a..7284a99e 100644 --- a/include/boost/regex/pending/object_cache.hpp +++ b/include/boost/regex/pending/object_cache.hpp @@ -19,14 +19,24 @@ #ifndef BOOST_REGEX_OBJECT_CACHE_HPP #define BOOST_REGEX_OBJECT_CACHE_HPP -#include +#include +#ifdef BOOST_REGEX_CXX03 #include +#define BOOST_REGEX_SHARED_PTR_NS boost +#else +#include +#define BOOST_REGEX_SHARED_PTR_NS std +#endif #include #include #include #include #ifdef BOOST_HAS_THREADS +#ifdef BOOST_REGEX_CXX03 #include +#else +#include +#endif #endif namespace boost{ @@ -35,16 +45,16 @@ template class object_cache { public: - typedef std::pair< ::boost::shared_ptr, Key const*> value_type; + typedef std::pair< BOOST_REGEX_SHARED_PTR_NS::shared_ptr, Key const*> value_type; typedef std::list list_type; typedef typename list_type::iterator list_iterator; typedef std::map map_type; typedef typename map_type::iterator map_iterator; typedef typename list_type::size_type size_type; - static boost::shared_ptr get(const Key& k, size_type l_max_cache_size); + static BOOST_REGEX_SHARED_PTR_NS::shared_ptr get(const Key& k, size_type l_max_cache_size); private: - static boost::shared_ptr do_get(const Key& k, size_type l_max_cache_size); + static BOOST_REGEX_SHARED_PTR_NS::shared_ptr do_get(const Key& k, size_type l_max_cache_size); struct data { @@ -62,13 +72,13 @@ private: #pragma warning(disable: 4702) #endif template -boost::shared_ptr object_cache::get(const Key& k, size_type l_max_cache_size) +BOOST_REGEX_SHARED_PTR_NS::shared_ptr object_cache::get(const Key& k, size_type l_max_cache_size) { #ifdef BOOST_HAS_THREADS +#ifdef BOOST_REGEX_CXX03 static boost::static_mutex mut = BOOST_STATIC_MUTEX_INIT; - boost::static_mutex::scoped_lock l(mut); - if(l) + if (l) { return do_get(k, l_max_cache_size); } @@ -78,7 +88,12 @@ boost::shared_ptr object_cache::get(const Key& k, siz // ::boost::throw_exception(std::runtime_error("Error in thread safety code: could not acquire a lock")); #if defined(BOOST_NO_UNREACHABLE_RETURN_DETECTION) || defined(BOOST_NO_EXCEPTIONS) - return boost::shared_ptr(); + return BOOST_REGEX_SHARED_PTR_NS::shared_ptr(); +#endif +#else + static std::mutex mut; + std::lock_guard l(mut); + return do_get(k, l_max_cache_size); #endif #else return do_get(k, l_max_cache_size); @@ -89,7 +104,7 @@ boost::shared_ptr object_cache::get(const Key& k, siz #endif template -boost::shared_ptr object_cache::do_get(const Key& k, size_type l_max_cache_size) +BOOST_REGEX_SHARED_PTR_NS::shared_ptr object_cache::do_get(const Key& k, size_type l_max_cache_size) { typedef typename object_cache::data object_data; typedef typename map_type::size_type map_size_type; @@ -112,11 +127,11 @@ boost::shared_ptr object_cache::do_get(const Key& k, temp.splice(temp.end(), s_data.cont, mpos->second); // and now place it at the end of the list: s_data.cont.splice(s_data.cont.end(), temp, temp.begin()); - BOOST_ASSERT(*(s_data.cont.back().second) == k); + BOOST_REGEX_ASSERT(*(s_data.cont.back().second) == k); // update index with new position: mpos->second = --(s_data.cont.end()); - BOOST_ASSERT(&(mpos->first) == mpos->second->second); - BOOST_ASSERT(&(mpos->first) == s_data.cont.back().second); + BOOST_REGEX_ASSERT(&(mpos->first) == mpos->second->second); + BOOST_REGEX_ASSERT(&(mpos->first) == s_data.cont.back().second); } return s_data.cont.back().first; } @@ -124,7 +139,7 @@ boost::shared_ptr object_cache::do_get(const Key& k, // if we get here then the item is not in the cache, // so create it: // - boost::shared_ptr result(new Object(k)); + BOOST_REGEX_SHARED_PTR_NS::shared_ptr result(new Object(k)); // // Add it to the list, and index it: // @@ -132,9 +147,9 @@ boost::shared_ptr object_cache::do_get(const Key& k, s_data.index.insert(std::make_pair(k, --(s_data.cont.end()))); s_data.cont.back().second = &(s_data.index.find(k)->first); map_size_type s = s_data.index.size(); - BOOST_ASSERT(s_data.index[k]->first.get() == result.get()); - BOOST_ASSERT(&(s_data.index.find(k)->first) == s_data.cont.back().second); - BOOST_ASSERT(s_data.index.find(k)->first == k); + BOOST_REGEX_ASSERT(s_data.index[k]->first.get() == result.get()); + BOOST_REGEX_ASSERT(&(s_data.index.find(k)->first) == s_data.cont.back().second); + BOOST_REGEX_ASSERT(s_data.index.find(k)->first == k); if(s > l_max_cache_size) { // @@ -152,7 +167,7 @@ boost::shared_ptr object_cache::do_get(const Key& k, ++pos; // now remove the items from our containers, // then order has to be as follows: - BOOST_ASSERT(s_data.index.find(*(condemmed->second)) != s_data.index.end()); + BOOST_REGEX_ASSERT(s_data.index.find(*(condemmed->second)) != s_data.index.end()); s_data.index.erase(*(condemmed->second)); s_data.cont.erase(condemmed); --s; @@ -160,13 +175,13 @@ boost::shared_ptr object_cache::do_get(const Key& k, else ++pos; } - BOOST_ASSERT(s_data.index[k]->first.get() == result.get()); - BOOST_ASSERT(&(s_data.index.find(k)->first) == s_data.cont.back().second); - BOOST_ASSERT(s_data.index.find(k)->first == k); + BOOST_REGEX_ASSERT(s_data.index[k]->first.get() == result.get()); + BOOST_REGEX_ASSERT(&(s_data.index.find(k)->first) == s_data.cont.back().second); + BOOST_REGEX_ASSERT(s_data.index.find(k)->first == k); } return result; } -} +#undef BOOST_REGEX_SHARED_PTR_NS #endif diff --git a/include/boost/regex/pending/unicode_iterator.hpp b/include/boost/regex/pending/unicode_iterator.hpp index becb17ad..2aabec61 100644 --- a/include/boost/regex/pending/unicode_iterator.hpp +++ b/include/boost/regex/pending/unicode_iterator.hpp @@ -61,7 +61,7 @@ Accepts UTF-32 code points and forwards them on as UTF-16 code points. #ifndef BOOST_REGEX_UNICODE_ITERATOR_HPP #define BOOST_REGEX_UNICODE_ITERATOR_HPP #include -#include +#include #include #include #include @@ -232,8 +232,8 @@ private: m_values[0] = static_cast(v >> 10) + detail::high_surrogate_base; m_values[1] = static_cast(v & detail::ten_bit_mask) + detail::low_surrogate_base; m_current = 0; - BOOST_ASSERT(detail::is_high_surrogate(m_values[0])); - BOOST_ASSERT(detail::is_low_surrogate(m_values[1])); + BOOST_REGEX_ASSERT(detail::is_high_surrogate(m_values[0])); + BOOST_REGEX_ASSERT(detail::is_low_surrogate(m_values[1])); } else { diff --git a/include/boost/regex/v4/basic_regex.hpp b/include/boost/regex/v4/basic_regex.hpp index c486c8d5..0408a754 100644 --- a/include/boost/regex/v4/basic_regex.hpp +++ b/include/boost/regex/v4/basic_regex.hpp @@ -617,32 +617,32 @@ public: // const BOOST_REGEX_DETAIL_NS::re_syntax_base* get_first_state()const { - BOOST_ASSERT(0 != m_pimpl.get()); + BOOST_REGEX_ASSERT(0 != m_pimpl.get()); return m_pimpl->get_first_state(); } unsigned get_restart_type()const { - BOOST_ASSERT(0 != m_pimpl.get()); + BOOST_REGEX_ASSERT(0 != m_pimpl.get()); return m_pimpl->get_restart_type(); } const unsigned char* get_map()const { - BOOST_ASSERT(0 != m_pimpl.get()); + BOOST_REGEX_ASSERT(0 != m_pimpl.get()); return m_pimpl->get_map(); } const ::boost::regex_traits_wrapper& get_traits()const { - BOOST_ASSERT(0 != m_pimpl.get()); + BOOST_REGEX_ASSERT(0 != m_pimpl.get()); return m_pimpl->get_traits(); } bool can_be_null()const { - BOOST_ASSERT(0 != m_pimpl.get()); + BOOST_REGEX_ASSERT(0 != m_pimpl.get()); return m_pimpl->can_be_null(); } const BOOST_REGEX_DETAIL_NS::regex_data& get_data()const { - BOOST_ASSERT(0 != m_pimpl.get()); + BOOST_REGEX_ASSERT(0 != m_pimpl.get()); return m_pimpl->get_data(); } boost::shared_ptr get_named_subs()const diff --git a/include/boost/regex/v4/basic_regex_creator.hpp b/include/boost/regex/v4/basic_regex_creator.hpp index 2d67313c..b9f02ece 100644 --- a/include/boost/regex/v4/basic_regex_creator.hpp +++ b/include/boost/regex/v4/basic_regex_creator.hpp @@ -58,8 +58,8 @@ struct digraph : public std::pair template digraph(const Seq& s) : std::pair() { - BOOST_ASSERT(s.size() <= 2); - BOOST_ASSERT(s.size()); + BOOST_REGEX_ASSERT(s.size() <= 2); + BOOST_REGEX_ASSERT(s.size()); this->first = s[0]; this->second = (s.size() > 1) ? s[1] : 0; } @@ -288,11 +288,11 @@ basic_regex_creator::basic_regex_creator(regex_datam_word_mask = m_word_mask; - BOOST_ASSERT(m_word_mask != 0); - BOOST_ASSERT(m_mask_space != 0); - BOOST_ASSERT(m_lower_mask != 0); - BOOST_ASSERT(m_upper_mask != 0); - BOOST_ASSERT(m_alpha_mask != 0); + BOOST_REGEX_ASSERT(m_word_mask != 0); + BOOST_REGEX_ASSERT(m_mask_space != 0); + BOOST_REGEX_ASSERT(m_lower_mask != 0); + BOOST_REGEX_ASSERT(m_upper_mask != 0); + BOOST_REGEX_ASSERT(m_alpha_mask != 0); } template @@ -580,7 +580,7 @@ re_syntax_base* basic_regex_creator::append_set( // Oops error: return 0; } - BOOST_ASSERT(c3[1] == charT(0)); + BOOST_REGEX_ASSERT(c3[1] == charT(0)); for(unsigned i = 0; i < (1u << CHAR_BIT); ++i) { c3[0] = static_cast(i); @@ -645,7 +645,7 @@ re_syntax_base* basic_regex_creator::append_set( while(sfirst != slast) { string_type s; - BOOST_ASSERT(static_cast(0) == sfirst->second); + BOOST_REGEX_ASSERT(static_cast(0) == sfirst->second); s = m_traits.transform_primary(&sfirst->first, &sfirst->first+1); if(s.empty()) return 0; // invalid or unsupported equivalence class @@ -1038,7 +1038,7 @@ int basic_regex_creator::calculate_backstep(re_syntax_base* state } else if(state->type == syntax_element_long_set_rep) { - BOOST_ASSERT(rep->next.p->type == syntax_element_long_set); + BOOST_REGEX_ASSERT(rep->next.p->type == syntax_element_long_set); if(static_cast*>(rep->next.p)->singleton == 0) return -1; if(rep->max != rep->min) @@ -1138,7 +1138,7 @@ void basic_regex_creator::create_startmap(re_syntax_base* state, } case syntax_element_recurse: { - BOOST_ASSERT(static_cast(state)->alt.p->type == syntax_element_startmark); + BOOST_REGEX_ASSERT(static_cast(state)->alt.p->type == syntax_element_startmark); recursion_sub = static_cast(static_cast(state)->alt.p)->index; if(m_recursion_checks[recursion_sub] & 1u) { diff --git a/include/boost/regex/v4/basic_regex_parser.hpp b/include/boost/regex/v4/basic_regex_parser.hpp index 77da995d..58096783 100644 --- a/include/boost/regex/v4/basic_regex_parser.hpp +++ b/include/boost/regex/v4/basic_regex_parser.hpp @@ -1948,7 +1948,7 @@ charT basic_regex_parser::unescape_character() template bool basic_regex_parser::parse_backref() { - BOOST_ASSERT(m_position != m_end); + BOOST_REGEX_ASSERT(m_position != m_end); const charT* pc = m_position; boost::intmax_t i = this->m_traits.toi(pc, pc + 1, 10); if((i == 0) || (((this->flags() & regbase::main_option_type) == regbase::perl_syntax_group) && (this->flags() & regbase::no_bk_refs))) @@ -2609,7 +2609,7 @@ option_group_jump: this->fail(regex_constants::error_paren, ::boost::BOOST_REGEX_DETAIL_NS::distance(m_base, m_end)); return false; } - BOOST_ASSERT(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_close_mark); + BOOST_REGEX_ASSERT(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_close_mark); ++m_position; // // restore the flags: @@ -3137,7 +3137,7 @@ bool basic_regex_parser::unwind_alts(std::ptrdiff_t last_paren_st m_alt_jumps.pop_back(); this->m_pdata->m_data.align(); re_jump* jmp = static_cast(this->getaddress(jump_offset)); - BOOST_ASSERT(jmp->type == syntax_element_jump); + BOOST_REGEX_ASSERT(jmp->type == syntax_element_jump); jmp->alt.i = this->m_pdata->m_data.size() - jump_offset; } return true; diff --git a/include/boost/regex/v4/c_regex_traits.hpp b/include/boost/regex/v4/c_regex_traits.hpp index 1c33b727..f966c4d4 100644 --- a/include/boost/regex/v4/c_regex_traits.hpp +++ b/include/boost/regex/v4/c_regex_traits.hpp @@ -23,7 +23,7 @@ #include #endif #ifndef BOOST_REGEX_WORKAROUND_HPP -#include +#include #endif #include @@ -277,7 +277,7 @@ inline c_regex_traits::char_class_type BOOST_REGEX_CALL c_regex_traits((std::tolower)(static_cast(s[i]))); idx = ::boost::BOOST_REGEX_DETAIL_NS::get_default_class_id(&*s.begin(), &*s.begin() + s.size()); } - BOOST_ASSERT(std::size_t(idx) + 1u < sizeof(masks) / sizeof(masks[0])); + BOOST_REGEX_ASSERT(std::size_t(idx) + 1u < sizeof(masks) / sizeof(masks[0])); return masks[idx + 1]; } @@ -433,7 +433,7 @@ inline c_regex_traits::char_class_type BOOST_REGEX_CALL c_regex_traits< s[i] = (std::towlower)(s[i]); idx = ::boost::BOOST_REGEX_DETAIL_NS::get_default_class_id(&*s.begin(), &*s.begin() + s.size()); } - BOOST_ASSERT(idx + 1 < static_cast(sizeof(masks) / sizeof(masks[0]))); + BOOST_REGEX_ASSERT(idx + 1 < static_cast(sizeof(masks) / sizeof(masks[0]))); return masks[idx + 1]; } diff --git a/include/boost/regex/v4/cpp_regex_traits.hpp b/include/boost/regex/v4/cpp_regex_traits.hpp index 801b0ac0..98b25151 100644 --- a/include/boost/regex/v4/cpp_regex_traits.hpp +++ b/include/boost/regex/v4/cpp_regex_traits.hpp @@ -29,16 +29,16 @@ #include #endif #ifndef BOOST_REGEX_TRAITS_DEFAULTS_HPP_INCLUDED -#include +#include #endif #ifdef BOOST_HAS_THREADS #include #endif #ifndef BOOST_REGEX_PRIMARY_TRANSFORM -#include +#include #endif #ifndef BOOST_REGEX_OBJECT_CACHE_HPP -#include +#include #endif #include @@ -508,7 +508,7 @@ typename cpp_regex_traits_implementation::string_type // we work around this elsewhere, but just assert here that // we adhere to gcc's (buggy) preconditions... // - BOOST_ASSERT(*p2 == 0); + BOOST_REGEX_ASSERT(*p2 == 0); string_type result; #if defined(_CPPLIB_VER) // @@ -588,7 +588,7 @@ typename cpp_regex_traits_implementation::string_type // we work around this elsewhere, but just assert here that // we adhere to gcc's (buggy) preconditions... // - BOOST_ASSERT(*p2 == 0); + BOOST_REGEX_ASSERT(*p2 == 0); // // swallowing all exceptions here is a bad idea // however at least one std lib will always throw @@ -646,7 +646,7 @@ typename cpp_regex_traits_implementation::string_type result2.append(1, static_cast(1 + static_cast(result[i]))).append(1, charT('b') - 1); } } - BOOST_ASSERT(std::find(result2.begin(), result2.end(), charT(0)) == result2.end()); + BOOST_REGEX_ASSERT(std::find(result2.begin(), result2.end(), charT(0)) == result2.end()); #ifndef BOOST_NO_EXCEPTIONS } catch(...) @@ -872,7 +872,7 @@ typename cpp_regex_traits_implementation::char_class_type return pos->second; } std::size_t state_id = 1 + BOOST_REGEX_DETAIL_NS::get_default_class_id(p1, p2); - BOOST_ASSERT(state_id < sizeof(masks) / sizeof(masks[0])); + BOOST_REGEX_ASSERT(state_id < sizeof(masks) / sizeof(masks[0])); return masks[state_id]; } diff --git a/include/boost/regex/v4/match_results.hpp b/include/boost/regex/v4/match_results.hpp index 7e509801..c580e4fc 100644 --- a/include/boost/regex/v4/match_results.hpp +++ b/include/boost/regex/v4/match_results.hpp @@ -474,7 +474,7 @@ public: // private access functions: void BOOST_REGEX_CALL set_second(BidiIterator i) { - BOOST_ASSERT(m_subs.size() > 2); + BOOST_REGEX_ASSERT(m_subs.size() > 2); m_subs[2].second = i; m_subs[2].matched = true; m_subs[0].first = i; @@ -490,7 +490,7 @@ public: if(pos) m_last_closed_paren = static_cast(pos); pos += 2; - BOOST_ASSERT(m_subs.size() > pos); + BOOST_REGEX_ASSERT(m_subs.size() > pos); m_subs[pos].second = i; m_subs[pos].matched = m; if((pos == 2) && !escape_k) @@ -531,7 +531,7 @@ public: } void BOOST_REGEX_CALL set_first(BidiIterator i) { - BOOST_ASSERT(m_subs.size() > 2); + BOOST_REGEX_ASSERT(m_subs.size() > 2); // set up prefix: m_subs[1].second = i; m_subs[1].matched = (m_subs[1].first != i); @@ -546,7 +546,7 @@ public: } void BOOST_REGEX_CALL set_first(BidiIterator i, size_type pos, bool escape_k = false) { - BOOST_ASSERT(pos+2 < m_subs.size()); + BOOST_REGEX_ASSERT(pos+2 < m_subs.size()); if(pos || escape_k) { m_subs[pos+2].first = i; @@ -650,15 +650,15 @@ void BOOST_REGEX_CALL match_results::maybe_assign(const } base1 = ::boost::BOOST_REGEX_DETAIL_NS::distance(l_base, p1->first); base2 = ::boost::BOOST_REGEX_DETAIL_NS::distance(l_base, p2->first); - BOOST_ASSERT(base1 >= 0); - BOOST_ASSERT(base2 >= 0); + BOOST_REGEX_ASSERT(base1 >= 0); + BOOST_REGEX_ASSERT(base2 >= 0); if(base1 < base2) return; if(base2 < base1) break; len1 = ::boost::BOOST_REGEX_DETAIL_NS::distance((BidiIterator)p1->first, (BidiIterator)p1->second); len2 = ::boost::BOOST_REGEX_DETAIL_NS::distance((BidiIterator)p2->first, (BidiIterator)p2->second); - BOOST_ASSERT(len1 >= 0); - BOOST_ASSERT(len2 >= 0); + BOOST_REGEX_ASSERT(len1 >= 0); + BOOST_REGEX_ASSERT(len2 >= 0); if((len1 != len2) || ((p1->matched == false) && (p2->matched == true))) break; if((p1->matched == true) && (p2->matched == false)) diff --git a/include/boost/regex/v4/perl_matcher_common.hpp b/include/boost/regex/v4/perl_matcher_common.hpp index dd767968..7cf0574b 100644 --- a/include/boost/regex/v4/perl_matcher_common.hpp +++ b/include/boost/regex/v4/perl_matcher_common.hpp @@ -622,7 +622,7 @@ bool perl_matcher::match_backref() if(index >= hash_value_mask) { named_subexpressions::range_type r = re.get_data().equal_range(index); - BOOST_ASSERT(r.first != r.second); + BOOST_REGEX_ASSERT(r.first != r.second); do { index = r.first->index; diff --git a/include/boost/regex/v4/perl_matcher_non_recursive.hpp b/include/boost/regex/v4/perl_matcher_non_recursive.hpp index 1042e794..9b770f15 100644 --- a/include/boost/regex/v4/perl_matcher_non_recursive.hpp +++ b/include/boost/regex/v4/perl_matcher_non_recursive.hpp @@ -111,7 +111,7 @@ struct save_state_init *end = reinterpret_cast(reinterpret_cast(*base)+BOOST_REGEX_BLOCKSIZE); --(*end); (void) new (*end)saved_state(0); - BOOST_ASSERT(*end > *base); + BOOST_REGEX_ASSERT(*end > *base); } ~save_state_init() { @@ -248,7 +248,7 @@ void perl_matcher::extend_stack() template inline void perl_matcher::push_matched_paren(int index, const sub_match& sub) { - //BOOST_ASSERT(index); + //BOOST_REGEX_ASSERT(index); saved_matched_paren* pmp = static_cast*>(m_backup_state); --pmp; if(pmp < m_stack_base) @@ -264,7 +264,7 @@ inline void perl_matcher::push_matched_paren(in template inline void perl_matcher::push_case_change(bool c) { - //BOOST_ASSERT(index); + //BOOST_REGEX_ASSERT(index); saved_change_case* pmp = static_cast(m_backup_state); --pmp; if(pmp < m_stack_base) @@ -492,7 +492,7 @@ bool perl_matcher::match_startmark() { // conditional expression: const re_alt* alt = static_cast(pstate->next.p); - BOOST_ASSERT(alt->type == syntax_element_alt); + BOOST_REGEX_ASSERT(alt->type == syntax_element_alt); pstate = alt->next.p; if(pstate->type == syntax_element_assert_backref) { @@ -503,7 +503,7 @@ bool perl_matcher::match_startmark() else { // zero width assertion, have to match this recursively: - BOOST_ASSERT(pstate->type == syntax_element_startmark); + BOOST_REGEX_ASSERT(pstate->type == syntax_element_startmark); bool negated = static_cast(pstate)->index == -2; BidiIterator saved_position = position; const re_syntax_base* next_pstate = static_cast(pstate->next.p)->alt.p->next.p; @@ -543,7 +543,7 @@ bool perl_matcher::match_startmark() } default: { - BOOST_ASSERT(index > 0); + BOOST_REGEX_ASSERT(index > 0); if((m_match_flags & match_nosubs) == 0) { push_matched_paren(index, (*m_presult)[index]); @@ -794,7 +794,7 @@ bool perl_matcher::match_char_repeat() #pragma option push -w-8008 -w-8066 -w-8004 #endif const re_repeat* rep = static_cast(pstate); - BOOST_ASSERT(1 == static_cast(rep->next.p)->length); + BOOST_REGEX_ASSERT(1 == static_cast(rep->next.p)->length); const char_type what = *reinterpret_cast(static_cast(rep->next.p) + 1); std::size_t count = 0; // @@ -1010,7 +1010,7 @@ bool perl_matcher::match_long_set_repeat() template bool perl_matcher::match_recursion() { - BOOST_ASSERT(pstate->type == syntax_element_recurse); + BOOST_REGEX_ASSERT(pstate->type == syntax_element_recurse); // // See if we've seen this recursion before at this location, if we have then // we need to prevent infinite recursion: @@ -1087,7 +1087,7 @@ bool perl_matcher::match_match() { if(!recursion_stack.empty()) { - BOOST_ASSERT(0 == recursion_stack.back().idx); + BOOST_REGEX_ASSERT(0 == recursion_stack.back().idx); pstate = recursion_stack.back().preturn_address; push_recursion(recursion_stack.back().idx, recursion_stack.back().preturn_address, m_presult, &recursion_stack.back().results); *m_presult = recursion_stack.back().results; @@ -1394,15 +1394,15 @@ bool perl_matcher::unwind_greedy_single_repeat( const re_repeat* rep = pmp->rep; std::size_t count = pmp->count; - BOOST_ASSERT(rep->next.p != 0); - BOOST_ASSERT(rep->alt.p != 0); + BOOST_REGEX_ASSERT(rep->next.p != 0); + BOOST_REGEX_ASSERT(rep->alt.p != 0); count -= rep->min; if((m_match_flags & match_partial) && (position == last)) m_has_partial_match = true; - BOOST_ASSERT(count); + BOOST_REGEX_ASSERT(count); position = pmp->last_position; // backtrack till we can skip out: @@ -1443,12 +1443,12 @@ bool perl_matcher::unwind_slow_dot_repeat(bool const re_repeat* rep = pmp->rep; std::size_t count = pmp->count; - BOOST_ASSERT(rep->type == syntax_element_dot_rep); - BOOST_ASSERT(rep->next.p != 0); - BOOST_ASSERT(rep->alt.p != 0); - BOOST_ASSERT(rep->next.p->type == syntax_element_wild); + BOOST_REGEX_ASSERT(rep->type == syntax_element_dot_rep); + BOOST_REGEX_ASSERT(rep->next.p != 0); + BOOST_REGEX_ASSERT(rep->alt.p != 0); + BOOST_REGEX_ASSERT(rep->next.p->type == syntax_element_wild); - BOOST_ASSERT(count < rep->max); + BOOST_REGEX_ASSERT(count < rep->max); pstate = rep->next.p; position = pmp->last_position; @@ -1508,7 +1508,7 @@ bool perl_matcher::unwind_fast_dot_repeat(bool const re_repeat* rep = pmp->rep; std::size_t count = pmp->count; - BOOST_ASSERT(count < rep->max); + BOOST_REGEX_ASSERT(count < rep->max); position = pmp->last_position; if(position != last) { @@ -1568,11 +1568,11 @@ bool perl_matcher::unwind_char_repeat(bool r) const char_type what = *reinterpret_cast(static_cast(pstate) + 1); position = pmp->last_position; - BOOST_ASSERT(rep->type == syntax_element_char_rep); - BOOST_ASSERT(rep->next.p != 0); - BOOST_ASSERT(rep->alt.p != 0); - BOOST_ASSERT(rep->next.p->type == syntax_element_literal); - BOOST_ASSERT(count < rep->max); + BOOST_REGEX_ASSERT(rep->type == syntax_element_char_rep); + BOOST_REGEX_ASSERT(rep->next.p != 0); + BOOST_REGEX_ASSERT(rep->alt.p != 0); + BOOST_REGEX_ASSERT(rep->next.p->type == syntax_element_literal); + BOOST_REGEX_ASSERT(count < rep->max); if(position != last) { @@ -1637,11 +1637,11 @@ bool perl_matcher::unwind_short_set_repeat(bool const unsigned char* map = static_cast(rep->next.p)->_map; position = pmp->last_position; - BOOST_ASSERT(rep->type == syntax_element_short_set_rep); - BOOST_ASSERT(rep->next.p != 0); - BOOST_ASSERT(rep->alt.p != 0); - BOOST_ASSERT(rep->next.p->type == syntax_element_set); - BOOST_ASSERT(count < rep->max); + BOOST_REGEX_ASSERT(rep->type == syntax_element_short_set_rep); + BOOST_REGEX_ASSERT(rep->next.p != 0); + BOOST_REGEX_ASSERT(rep->alt.p != 0); + BOOST_REGEX_ASSERT(rep->next.p->type == syntax_element_set); + BOOST_REGEX_ASSERT(count < rep->max); if(position != last) { @@ -1707,11 +1707,11 @@ bool perl_matcher::unwind_long_set_repeat(bool const re_set_long* set = static_cast*>(pstate); position = pmp->last_position; - BOOST_ASSERT(rep->type == syntax_element_long_set_rep); - BOOST_ASSERT(rep->next.p != 0); - BOOST_ASSERT(rep->alt.p != 0); - BOOST_ASSERT(rep->next.p->type == syntax_element_long_set); - BOOST_ASSERT(count < rep->max); + BOOST_REGEX_ASSERT(rep->type == syntax_element_long_set_rep); + BOOST_REGEX_ASSERT(rep->next.p != 0); + BOOST_REGEX_ASSERT(rep->alt.p != 0); + BOOST_REGEX_ASSERT(rep->next.p->type == syntax_element_long_set); + BOOST_REGEX_ASSERT(count < rep->max); if(position != last) { diff --git a/include/boost/regex/v4/perl_matcher_recursive.hpp b/include/boost/regex/v4/perl_matcher_recursive.hpp index c33475f0..7d262fe2 100644 --- a/include/boost/regex/v4/perl_matcher_recursive.hpp +++ b/include/boost/regex/v4/perl_matcher_recursive.hpp @@ -195,7 +195,7 @@ bool perl_matcher::match_startmark() { // conditional expression: const re_alt* alt = static_cast(pstate->next.p); - BOOST_ASSERT(alt->type == syntax_element_alt); + BOOST_REGEX_ASSERT(alt->type == syntax_element_alt); pstate = alt->next.p; if(pstate->type == syntax_element_assert_backref) { @@ -206,7 +206,7 @@ bool perl_matcher::match_startmark() else { // zero width assertion, have to match this recursively: - BOOST_ASSERT(pstate->type == syntax_element_startmark); + BOOST_REGEX_ASSERT(pstate->type == syntax_element_startmark); bool negated = static_cast(pstate)->index == -2; BidiIterator saved_position = position; const re_syntax_base* next_pstate = static_cast(pstate->next.p)->alt.p->next.p; @@ -235,7 +235,7 @@ bool perl_matcher::match_startmark() } default: { - BOOST_ASSERT(index > 0); + BOOST_REGEX_ASSERT(index > 0); if((m_match_flags & match_nosubs) == 0) { backup_subex sub(*m_presult, index); @@ -552,7 +552,7 @@ bool perl_matcher::match_char_repeat() #pragma option push -w-8008 -w-8066 -w-8004 #endif const re_repeat* rep = static_cast(pstate); - BOOST_ASSERT(1 == static_cast(rep->next.p)->length); + BOOST_REGEX_ASSERT(1 == static_cast(rep->next.p)->length); const char_type what = *reinterpret_cast(static_cast(rep->next.p) + 1); // // start by working out how much we can skip: @@ -892,7 +892,7 @@ bool perl_matcher::backtrack_till_match(std::si template bool perl_matcher::match_recursion() { - BOOST_ASSERT(pstate->type == syntax_element_recurse); + BOOST_REGEX_ASSERT(pstate->type == syntax_element_recurse); // // Set new call stack: // @@ -987,7 +987,7 @@ bool perl_matcher::match_match() { if(!recursion_stack.empty()) { - BOOST_ASSERT(0 == recursion_stack.back().idx); + BOOST_REGEX_ASSERT(0 == recursion_stack.back().idx); const re_syntax_base* saved_state = pstate = recursion_stack.back().preturn_address; *m_presult = recursion_stack.back().results; recursion_stack.pop_back(); diff --git a/include/boost/regex/v4/regex_format.hpp b/include/boost/regex/v4/regex_format.hpp index 33c4a5cb..9401fa30 100644 --- a/include/boost/regex/v4/regex_format.hpp +++ b/include/boost/regex/v4/regex_format.hpp @@ -251,7 +251,7 @@ void basic_regex_formatter::format m_have_conditional = have_conditional; if(m_position == m_end) return; - BOOST_ASSERT(*m_position == static_cast(')')); + BOOST_REGEX_ASSERT(*m_position == static_cast(')')); ++m_position; // skip the closing ')' break; } @@ -307,7 +307,7 @@ void basic_regex_formatter::format // On entry *m_position points to a '$' character // output the information that goes with it: // - BOOST_ASSERT(*m_position == '$'); + BOOST_REGEX_ASSERT(*m_position == '$'); // // see if this is a trailing '$': // @@ -656,7 +656,7 @@ void basic_regex_formatter::format len = ::boost::BOOST_REGEX_DETAIL_NS::distance(m_position, m_end); len = (std::min)(static_cast(4), len); v = this->toi(m_position, m_position + len, 8); - BOOST_ASSERT(v >= 0); + BOOST_REGEX_ASSERT(v >= 0); put(static_cast(v)); break; } diff --git a/include/boost/regex/v4/regex_raw_buffer.hpp b/include/boost/regex/v4/regex_raw_buffer.hpp index c73a3e90..ac27e1a2 100644 --- a/include/boost/regex/v4/regex_raw_buffer.hpp +++ b/include/boost/regex/v4/regex_raw_buffer.hpp @@ -158,7 +158,7 @@ public: void* BOOST_REGEX_CALL insert(size_type pos, size_type n) { - BOOST_ASSERT(pos <= size_type(end - start)); + BOOST_REGEX_ASSERT(pos <= size_type(end - start)); if (size_type(last - end) < n) resize(n + (end - start)); void* result = start + pos; diff --git a/include/boost/regex/v4/regex_traits_defaults.hpp b/include/boost/regex/v4/regex_traits_defaults.hpp index 2a6c0d12..26b9252c 100644 --- a/include/boost/regex/v4/regex_traits_defaults.hpp +++ b/include/boost/regex/v4/regex_traits_defaults.hpp @@ -34,12 +34,12 @@ #include #ifndef BOOST_REGEX_SYNTAX_TYPE_HPP -#include +#include #endif #ifndef BOOST_REGEX_ERROR_TYPE_HPP -#include +#include #endif -#include +#include #include #include diff --git a/include/boost/regex/v4/w32_regex_traits.hpp b/include/boost/regex/v4/w32_regex_traits.hpp index 329a56db..e1ac5d5f 100644 --- a/include/boost/regex/v4/w32_regex_traits.hpp +++ b/include/boost/regex/v4/w32_regex_traits.hpp @@ -25,16 +25,16 @@ #include #endif #ifndef BOOST_REGEX_TRAITS_DEFAULTS_HPP_INCLUDED -#include +#include #endif #ifdef BOOST_HAS_THREADS #include #endif #ifndef BOOST_REGEX_PRIMARY_TRANSFORM -#include +#include #endif #ifndef BOOST_REGEX_OBJECT_CACHE_HPP -#include +#include #endif #define VC_EXTRALEAN @@ -794,21 +794,21 @@ namespace BOOST_REGEX_DETAIL_NS { char_map[ii] = static_cast(ii); #ifndef BOOST_NO_ANSI_APIS int r = ::LCMapStringA(this->m_locale, LCMAP_LOWERCASE, char_map, 1 << CHAR_BIT, this->m_lower_map, 1 << CHAR_BIT); - BOOST_ASSERT(r != 0); + BOOST_REGEX_ASSERT(r != 0); #else UINT code_page = get_code_page_for_locale_id(this->m_locale); - BOOST_ASSERT(code_page != 0); + BOOST_REGEX_ASSERT(code_page != 0); WCHAR wide_char_map[1 << CHAR_BIT]; int conv_r = ::MultiByteToWideChar(code_page, 0, char_map, 1 << CHAR_BIT, wide_char_map, 1 << CHAR_BIT); - BOOST_ASSERT(conv_r != 0); + BOOST_REGEX_ASSERT(conv_r != 0); WCHAR wide_lower_map[1 << CHAR_BIT]; int r = ::LCMapStringW(this->m_locale, LCMAP_LOWERCASE, wide_char_map, 1 << CHAR_BIT, wide_lower_map, 1 << CHAR_BIT); - BOOST_ASSERT(r != 0); + BOOST_REGEX_ASSERT(r != 0); conv_r = ::WideCharToMultiByte(code_page, 0, wide_lower_map, r, this->m_lower_map, 1 << CHAR_BIT, NULL, NULL); - BOOST_ASSERT(conv_r != 0); + BOOST_REGEX_ASSERT(conv_r != 0); #endif if (r < (1 << CHAR_BIT)) { @@ -823,7 +823,7 @@ namespace BOOST_REGEX_DETAIL_NS { #else r = ::GetStringTypeExW(this->m_locale, CT_CTYPE1, wide_char_map, 1 << CHAR_BIT, this->m_type_map); #endif - BOOST_ASSERT(0 != r); + BOOST_REGEX_ASSERT(0 != r); } inline lcid_type BOOST_REGEX_CALL w32_get_default_locale() diff --git a/include/boost/regex/v5/basic_regex.hpp b/include/boost/regex/v5/basic_regex.hpp index 0e6f232e..3686f939 100644 --- a/include/boost/regex/v5/basic_regex.hpp +++ b/include/boost/regex/v5/basic_regex.hpp @@ -19,9 +19,6 @@ #ifndef BOOST_REGEX_V5_BASIC_REGEX_HPP #define BOOST_REGEX_V5_BASIC_REGEX_HPP -#include -#include - #ifdef BOOST_MSVC #pragma warning(push) #pragma warning(disable: 4103) @@ -33,6 +30,8 @@ #pragma warning(pop) #endif +#include + namespace boost{ #ifdef BOOST_MSVC #pragma warning(push) @@ -75,7 +74,12 @@ static const int hash_value_mask = 1 << (std::numeric_limits::digits - 1); template inline int hash_value_from_capture_name(Iterator i, Iterator j) { - std::size_t r = boost::hash_range(i, j); + std::size_t r = 0; + while (i != j) + { + r ^= *i + 0x9e3779b9 + (r << 6) + (r >> 2); + ++i; + } r %= ((std::numeric_limits::max)()); return static_cast(r) | hash_value_mask; } @@ -169,7 +173,7 @@ struct regex_data : public named_subexpressions typedef regex_constants::syntax_option_type flag_type; typedef std::size_t size_type; - regex_data(const ::boost::shared_ptr< + regex_data(const ::std::shared_ptr< ::boost::regex_traits_wrapper >& t) : m_ptraits(t), m_flags(0), m_status(0), m_expression(0), m_expression_len(0), m_mark_count(0), m_first_state(0), m_restart_type(0), @@ -185,7 +189,7 @@ struct regex_data : public named_subexpressions #endif m_can_be_null(0), m_word_mask(0), m_has_recursions(false), m_disable_match_any(false) {} - ::boost::shared_ptr< + ::std::shared_ptr< ::boost::regex_traits_wrapper > m_ptraits; // traits class instance flag_type m_flags; // flags with which we were compiled @@ -221,7 +225,7 @@ public: typedef const charT* const_iterator; basic_regex_implementation(){} - basic_regex_implementation(const ::boost::shared_ptr< + basic_regex_implementation(const ::std::shared_ptr< ::boost::regex_traits_wrapper >& t) : regex_data(t) {} void assign(const charT* arg_first, @@ -617,41 +621,41 @@ public: // const BOOST_REGEX_DETAIL_NS::re_syntax_base* get_first_state()const { - BOOST_ASSERT(0 != m_pimpl.get()); + BOOST_REGEX_ASSERT(0 != m_pimpl.get()); return m_pimpl->get_first_state(); } unsigned get_restart_type()const { - BOOST_ASSERT(0 != m_pimpl.get()); + BOOST_REGEX_ASSERT(0 != m_pimpl.get()); return m_pimpl->get_restart_type(); } const unsigned char* get_map()const { - BOOST_ASSERT(0 != m_pimpl.get()); + BOOST_REGEX_ASSERT(0 != m_pimpl.get()); return m_pimpl->get_map(); } const ::boost::regex_traits_wrapper& get_traits()const { - BOOST_ASSERT(0 != m_pimpl.get()); + BOOST_REGEX_ASSERT(0 != m_pimpl.get()); return m_pimpl->get_traits(); } bool can_be_null()const { - BOOST_ASSERT(0 != m_pimpl.get()); + BOOST_REGEX_ASSERT(0 != m_pimpl.get()); return m_pimpl->can_be_null(); } const BOOST_REGEX_DETAIL_NS::regex_data& get_data()const { - BOOST_ASSERT(0 != m_pimpl.get()); + BOOST_REGEX_ASSERT(0 != m_pimpl.get()); return m_pimpl->get_data(); } - boost::shared_ptr get_named_subs()const + std::shared_ptr get_named_subs()const { return m_pimpl; } private: - shared_ptr > m_pimpl; + std::shared_ptr > m_pimpl; }; // @@ -665,14 +669,14 @@ basic_regex& basic_regex::do_assign(const charT* p const charT* p2, flag_type f) { - shared_ptr > temp; + std::shared_ptr > temp; if(!m_pimpl.get()) { - temp = shared_ptr >(new BOOST_REGEX_DETAIL_NS::basic_regex_implementation()); + temp = std::shared_ptr >(new BOOST_REGEX_DETAIL_NS::basic_regex_implementation()); } else { - temp = shared_ptr >(new BOOST_REGEX_DETAIL_NS::basic_regex_implementation(m_pimpl->m_ptraits)); + temp = std::shared_ptr >(new BOOST_REGEX_DETAIL_NS::basic_regex_implementation(m_pimpl->m_ptraits)); } temp->assign(p1, p2, f); temp.swap(m_pimpl); @@ -682,7 +686,7 @@ basic_regex& basic_regex::do_assign(const charT* p template typename basic_regex::locale_type BOOST_REGEX_CALL basic_regex::imbue(locale_type l) { - shared_ptr > temp(new BOOST_REGEX_DETAIL_NS::basic_regex_implementation()); + std::shared_ptr > temp(new BOOST_REGEX_DETAIL_NS::basic_regex_implementation()); locale_type result = temp->imbue(l); temp.swap(m_pimpl); return result; diff --git a/include/boost/regex/v5/basic_regex_creator.hpp b/include/boost/regex/v5/basic_regex_creator.hpp index c83c1cf9..fd14132e 100644 --- a/include/boost/regex/v5/basic_regex_creator.hpp +++ b/include/boost/regex/v5/basic_regex_creator.hpp @@ -58,8 +58,8 @@ struct digraph : public std::pair template digraph(const Seq& s) : std::pair() { - BOOST_ASSERT(s.size() <= 2); - BOOST_ASSERT(s.size()); + BOOST_REGEX_ASSERT(s.size() <= 2); + BOOST_REGEX_ASSERT(s.size()); this->first = s[0]; this->second = (s.size() > 1) ? s[1] : 0; } @@ -233,8 +233,8 @@ public: re_syntax_base* insert_state(std::ptrdiff_t pos, syntax_element_type t, std::size_t s = sizeof(re_syntax_base)); re_literal* append_literal(charT c); re_syntax_base* append_set(const basic_char_set& char_set); - re_syntax_base* append_set(const basic_char_set& char_set, mpl::false_*); - re_syntax_base* append_set(const basic_char_set& char_set, mpl::true_*); + re_syntax_base* append_set(const basic_char_set& char_set, std::integral_constant*); + re_syntax_base* append_set(const basic_char_set& char_set, std::integral_constant*); void finalize(const charT* p1, const charT* p2); protected: regex_data* m_pdata; // pointer to the basic_regex_data struct we are filling in @@ -288,11 +288,11 @@ basic_regex_creator::basic_regex_creator(regex_datam_word_mask = m_word_mask; - BOOST_ASSERT(m_word_mask != 0); - BOOST_ASSERT(m_mask_space != 0); - BOOST_ASSERT(m_lower_mask != 0); - BOOST_ASSERT(m_upper_mask != 0); - BOOST_ASSERT(m_alpha_mask != 0); + BOOST_REGEX_ASSERT(m_word_mask != 0); + BOOST_REGEX_ASSERT(m_mask_space != 0); + BOOST_REGEX_ASSERT(m_lower_mask != 0); + BOOST_REGEX_ASSERT(m_upper_mask != 0); + BOOST_REGEX_ASSERT(m_alpha_mask != 0); } template @@ -362,15 +362,15 @@ template inline re_syntax_base* basic_regex_creator::append_set( const basic_char_set& char_set) { - typedef mpl::bool_< (sizeof(charT) == 1) > truth_type; + typedef std::integral_constant truth_type; return char_set.has_digraphs() - ? append_set(char_set, static_cast(0)) + ? append_set(char_set, static_cast*>(0)) : append_set(char_set, static_cast(0)); } template re_syntax_base* basic_regex_creator::append_set( - const basic_char_set& char_set, mpl::false_*) + const basic_char_set& char_set, std::integral_constant*) { typedef typename traits::string_type string_type; typedef typename basic_char_set::list_iterator item_iterator; @@ -381,9 +381,9 @@ re_syntax_base* basic_regex_creator::append_set( // // fill in the basics: // - result->csingles = static_cast(::boost::BOOST_REGEX_DETAIL_NS::distance(char_set.singles_begin(), char_set.singles_end())); - result->cranges = static_cast(::boost::BOOST_REGEX_DETAIL_NS::distance(char_set.ranges_begin(), char_set.ranges_end())) / 2; - result->cequivalents = static_cast(::boost::BOOST_REGEX_DETAIL_NS::distance(char_set.equivalents_begin(), char_set.equivalents_end())); + result->csingles = static_cast(std::distance(char_set.singles_begin(), char_set.singles_end())); + result->cranges = static_cast(std::distance(char_set.ranges_begin(), char_set.ranges_end())) / 2; + result->cequivalents = static_cast(std::distance(char_set.equivalents_begin(), char_set.equivalents_end())); result->cclasses = char_set.classes(); result->cnclasses = char_set.negated_classes(); if(flags() & regbase::icase) @@ -478,10 +478,10 @@ re_syntax_base* basic_regex_creator::append_set( return 0; } charT* p = static_cast(this->m_pdata->m_data.extend(sizeof(charT) * (s1.size() + s2.size() + 2) ) ); - BOOST_REGEX_DETAIL_NS::copy(s1.begin(), s1.end(), p); + std::copy(s1.begin(), s1.end(), p); p[s1.size()] = charT(0); p += s1.size() + 1; - BOOST_REGEX_DETAIL_NS::copy(s2.begin(), s2.end(), p); + std::copy(s2.begin(), s2.end(), p); p[s2.size()] = charT(0); } // @@ -502,7 +502,7 @@ re_syntax_base* basic_regex_creator::append_set( if(s.empty()) return 0; // invalid or unsupported equivalence class charT* p = static_cast(this->m_pdata->m_data.extend(sizeof(charT) * (s.size()+1) ) ); - BOOST_REGEX_DETAIL_NS::copy(s.begin(), s.end(), p); + std::copy(s.begin(), s.end(), p); p[s.size()] = charT(0); ++sfirst; } @@ -529,7 +529,7 @@ inline bool char_less(signed char t1, signed char t2) template re_syntax_base* basic_regex_creator::append_set( - const basic_char_set& char_set, mpl::true_*) + const basic_char_set& char_set, std::integral_constant*) { typedef typename traits::string_type string_type; typedef typename basic_char_set::list_iterator item_iterator; @@ -580,7 +580,7 @@ re_syntax_base* basic_regex_creator::append_set( // Oops error: return 0; } - BOOST_ASSERT(c3[1] == charT(0)); + BOOST_REGEX_ASSERT(c3[1] == charT(0)); for(unsigned i = 0; i < (1u << CHAR_BIT); ++i) { c3[0] = static_cast(i); @@ -645,7 +645,7 @@ re_syntax_base* basic_regex_creator::append_set( while(sfirst != slast) { string_type s; - BOOST_ASSERT(static_cast(0) == sfirst->second); + BOOST_REGEX_ASSERT(static_cast(0) == sfirst->second); s = m_traits.transform_primary(&sfirst->first, &sfirst->first+1); if(s.empty()) return 0; // invalid or unsupported equivalence class @@ -681,7 +681,7 @@ void basic_regex_creator::finalize(const charT* p1, const charT* m_pdata->m_expression_len = len; charT* ps = static_cast(m_pdata->m_data.extend(sizeof(charT) * (1 + (p2 - p1)))); m_pdata->m_expression = ps; - BOOST_REGEX_DETAIL_NS::copy(p1, p2, ps); + std::copy(p1, p2, ps); ps[p2 - p1] = 0; // fill in our other data... // successful parsing implies a zero status: @@ -1038,7 +1038,7 @@ int basic_regex_creator::calculate_backstep(re_syntax_base* state } else if(state->type == syntax_element_long_set_rep) { - BOOST_ASSERT(rep->next.p->type == syntax_element_long_set); + BOOST_REGEX_ASSERT(rep->next.p->type == syntax_element_long_set); if(static_cast*>(rep->next.p)->singleton == 0) return -1; if(rep->max != rep->min) @@ -1138,7 +1138,7 @@ void basic_regex_creator::create_startmap(re_syntax_base* state, } case syntax_element_recurse: { - BOOST_ASSERT(static_cast(state)->alt.p->type == syntax_element_startmark); + BOOST_REGEX_ASSERT(static_cast(state)->alt.p->type == syntax_element_startmark); recursion_sub = static_cast(static_cast(state)->alt.p)->index; if(m_recursion_checks[recursion_sub] & 1u) { diff --git a/include/boost/regex/v5/basic_regex_parser.hpp b/include/boost/regex/v5/basic_regex_parser.hpp index 85ca3203..a3e0b3c6 100644 --- a/include/boost/regex/v5/basic_regex_parser.hpp +++ b/include/boost/regex/v5/basic_regex_parser.hpp @@ -44,19 +44,19 @@ namespace BOOST_REGEX_DETAIL_NS{ #endif #endif -inline boost::intmax_t umax(mpl::false_ const&) +inline boost::intmax_t umax(std::integral_constant const&) { // Get out clause here, just in case numeric_limits is unspecialized: return std::numeric_limits::is_specialized ? (std::numeric_limits::max)() : INT_MAX; } -inline boost::intmax_t umax(mpl::true_ const&) +inline boost::intmax_t umax(std::integral_constant const&) { return (std::numeric_limits::max)(); } inline boost::intmax_t umax() { - return umax(mpl::bool_::digits >= std::numeric_limits::digits>()); + return umax(std::integral_constant::digits >= std::numeric_limits::digits>()); } template @@ -190,7 +190,7 @@ void basic_regex_parser::parse(const charT* p1, const charT* p2, // have had an unexpected ')' : if(!result) { - fail(regex_constants::error_paren, ::boost::BOOST_REGEX_DETAIL_NS::distance(m_base, m_position), "Found a closing ) with no corresponding opening parenthesis."); + fail(regex_constants::error_paren, std::distance(m_base, m_position), "Found a closing ) with no corresponding opening parenthesis."); return; } // if an error has been set then give up now: @@ -531,7 +531,7 @@ bool basic_regex_parser::parse_open_paren() // if(m_position == m_end) { - this->fail(regex_constants::error_paren, ::boost::BOOST_REGEX_DETAIL_NS::distance(m_base, m_end)); + this->fail(regex_constants::error_paren, std::distance(m_base, m_end)); return false; } if(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_close_mark) @@ -1016,7 +1016,7 @@ bool basic_regex_parser::parse_repeat(std::size_t low, std::size_ } if(0 == this->m_last_state) { - fail(regex_constants::error_badrepeat, ::boost::BOOST_REGEX_DETAIL_NS::distance(m_base, m_position), "Nothing to repeat."); + fail(regex_constants::error_badrepeat, std::distance(m_base, m_position), "Nothing to repeat."); return false; } if(this->m_last_state->type == syntax_element_endmark) @@ -1741,19 +1741,19 @@ digraph basic_regex_parser::get_next_set_literal(basic_cha // does a value fit in the specified charT type? // template -bool valid_value(charT, boost::intmax_t v, const mpl::true_&) +bool valid_value(charT, boost::intmax_t v, const std::integral_constant&) { return (v >> (sizeof(charT) * CHAR_BIT)) == 0; } template -bool valid_value(charT, boost::intmax_t, const mpl::false_&) +bool valid_value(charT, boost::intmax_t, const std::integral_constant&) { return true; // v will alsways fit in a charT } template bool valid_value(charT c, boost::intmax_t v) { - return valid_value(c, v, mpl::bool_<(sizeof(charT) < sizeof(boost::intmax_t))>()); + return valid_value(c, v, std::integral_constant()); } template @@ -1864,7 +1864,7 @@ charT basic_regex_parser::unescape_character() { // an octal escape sequence, the first character must be a zero // followed by up to 3 octal digits: - std::ptrdiff_t len = (std::min)(::boost::BOOST_REGEX_DETAIL_NS::distance(m_position, m_end), static_cast(4)); + std::ptrdiff_t len = (std::min)(std::distance(m_position, m_end), static_cast(4)); const charT* bp = m_position; boost::intmax_t val = this->m_traits.toi(bp, bp + 1, 8); if(val != 0) @@ -1948,7 +1948,7 @@ charT basic_regex_parser::unescape_character() template bool basic_regex_parser::parse_backref() { - BOOST_ASSERT(m_position != m_end); + BOOST_REGEX_ASSERT(m_position != m_end); const charT* pc = m_position; boost::intmax_t i = this->m_traits.toi(pc, pc + 1, 10); if((i == 0) || (((this->flags() & regbase::main_option_type) == regbase::perl_syntax_group) && (this->flags() & regbase::no_bk_refs))) @@ -2606,10 +2606,10 @@ option_group_jump: // Rewind to start of (? sequence: --m_position; while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position; - this->fail(regex_constants::error_paren, ::boost::BOOST_REGEX_DETAIL_NS::distance(m_base, m_end)); + this->fail(regex_constants::error_paren, std::distance(m_base, m_end)); return false; } - BOOST_ASSERT(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_close_mark); + BOOST_REGEX_ASSERT(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_close_mark); ++m_position; // // restore the flags: @@ -3137,7 +3137,7 @@ bool basic_regex_parser::unwind_alts(std::ptrdiff_t last_paren_st m_alt_jumps.pop_back(); this->m_pdata->m_data.align(); re_jump* jmp = static_cast(this->getaddress(jump_offset)); - BOOST_ASSERT(jmp->type == syntax_element_jump); + BOOST_REGEX_ASSERT(jmp->type == syntax_element_jump); jmp->alt.i = this->m_pdata->m_data.size() - jump_offset; } return true; diff --git a/include/boost/regex/v5/c_regex_traits.hpp b/include/boost/regex/v5/c_regex_traits.hpp index 1c33b727..8f76f5e8 100644 --- a/include/boost/regex/v5/c_regex_traits.hpp +++ b/include/boost/regex/v5/c_regex_traits.hpp @@ -277,7 +277,7 @@ inline c_regex_traits::char_class_type BOOST_REGEX_CALL c_regex_traits((std::tolower)(static_cast(s[i]))); idx = ::boost::BOOST_REGEX_DETAIL_NS::get_default_class_id(&*s.begin(), &*s.begin() + s.size()); } - BOOST_ASSERT(std::size_t(idx) + 1u < sizeof(masks) / sizeof(masks[0])); + BOOST_REGEX_ASSERT(std::size_t(idx) + 1u < sizeof(masks) / sizeof(masks[0])); return masks[idx + 1]; } @@ -433,7 +433,7 @@ inline c_regex_traits::char_class_type BOOST_REGEX_CALL c_regex_traits< s[i] = (std::towlower)(s[i]); idx = ::boost::BOOST_REGEX_DETAIL_NS::get_default_class_id(&*s.begin(), &*s.begin() + s.size()); } - BOOST_ASSERT(idx + 1 < static_cast(sizeof(masks) / sizeof(masks[0]))); + BOOST_REGEX_ASSERT(idx + 1 < static_cast(sizeof(masks) / sizeof(masks[0]))); return masks[idx + 1]; } diff --git a/include/boost/regex/v5/cpp_regex_traits.hpp b/include/boost/regex/v5/cpp_regex_traits.hpp index 801b0ac0..03c38b89 100644 --- a/include/boost/regex/v5/cpp_regex_traits.hpp +++ b/include/boost/regex/v5/cpp_regex_traits.hpp @@ -19,9 +19,10 @@ #ifndef BOOST_CPP_REGEX_TRAITS_HPP_INCLUDED #define BOOST_CPP_REGEX_TRAITS_HPP_INCLUDED -#include -#include -#include +#include +#include +#include +#include #ifndef BOOST_NO_STD_LOCALE @@ -32,13 +33,13 @@ #include #endif #ifdef BOOST_HAS_THREADS -#include +#include #endif #ifndef BOOST_REGEX_PRIMARY_TRANSFORM #include #endif #ifndef BOOST_REGEX_OBJECT_CACHE_HPP -#include +#include #endif #include @@ -109,14 +110,12 @@ template typename parser_buf::pos_type parser_buf::seekoff(off_type off, ::std::ios_base::seekdir way, ::std::ios_base::openmode which) { - typedef typename boost::int_t::least cast_type; - if(which & ::std::ios_base::out) return pos_type(off_type(-1)); std::ptrdiff_t size = this->egptr() - this->eback(); std::ptrdiff_t pos = this->gptr() - this->eback(); charT* g = this->eback(); - switch(static_cast(way)) + switch(static_cast(way)) { case ::std::ios_base::beg: if((off < 0) || (off > size)) @@ -417,7 +416,7 @@ class cpp_regex_traits_implementation : public cpp_regex_traits_char_layer::char_class_type char_class_type; typedef typename std::ctype::mask native_mask_type; - typedef typename boost::make_unsigned::type unsigned_native_mask_type; + typedef typename std::make_unsigned::type unsigned_native_mask_type; #ifndef BOOST_REGEX_BUGGY_CTYPE_FACET BOOST_STATIC_CONSTANT(char_class_type, mask_blank = 1u << 24); BOOST_STATIC_CONSTANT(char_class_type, mask_word = 1u << 25); @@ -508,7 +507,7 @@ typename cpp_regex_traits_implementation::string_type // we work around this elsewhere, but just assert here that // we adhere to gcc's (buggy) preconditions... // - BOOST_ASSERT(*p2 == 0); + BOOST_REGEX_ASSERT(*p2 == 0); string_type result; #if defined(_CPPLIB_VER) // @@ -588,7 +587,7 @@ typename cpp_regex_traits_implementation::string_type // we work around this elsewhere, but just assert here that // we adhere to gcc's (buggy) preconditions... // - BOOST_ASSERT(*p2 == 0); + BOOST_REGEX_ASSERT(*p2 == 0); // // swallowing all exceptions here is a bad idea // however at least one std lib will always throw @@ -646,7 +645,7 @@ typename cpp_regex_traits_implementation::string_type result2.append(1, static_cast(1 + static_cast(result[i]))).append(1, charT('b') - 1); } } - BOOST_ASSERT(std::find(result2.begin(), result2.end(), charT(0)) == result2.end()); + BOOST_REGEX_ASSERT(std::find(result2.begin(), result2.end(), charT(0)) == result2.end()); #ifndef BOOST_NO_EXCEPTIONS } catch(...) @@ -872,7 +871,7 @@ typename cpp_regex_traits_implementation::char_class_type return pos->second; } std::size_t state_id = 1 + BOOST_REGEX_DETAIL_NS::get_default_class_id(p1, p2); - BOOST_ASSERT(state_id < sizeof(masks) / sizeof(masks[0])); + BOOST_REGEX_ASSERT(state_id < sizeof(masks) / sizeof(masks[0])); return masks[state_id]; } @@ -900,7 +899,7 @@ bool cpp_regex_traits_implementation::isctype(const charT c, char_class_t template -inline boost::shared_ptr > create_cpp_regex_traits(const std::locale& l) +inline std::shared_ptr > create_cpp_regex_traits(const std::locale& l) { cpp_regex_traits_base key(l); return ::boost::object_cache, cpp_regex_traits_implementation >::get(key, 5); @@ -918,7 +917,7 @@ public: typedef std::size_t size_type; typedef std::basic_string string_type; typedef std::locale locale_type; - typedef boost::uint_least32_t char_class_type; + typedef std::uint_least32_t char_class_type; struct boost_extensions_tag{}; @@ -1027,7 +1026,7 @@ public: return m_pimpl->isctype(c, f); #endif } - boost::intmax_t toi(const charT*& p1, const charT* p2, int radix)const; + std::intmax_t toi(const charT*& p1, const charT* p2, int radix)const; int value(charT c, int radix)const { const charT* pc = &c; @@ -1056,20 +1055,20 @@ public: static std::string get_catalog_name(); private: - boost::shared_ptr > m_pimpl; + std::shared_ptr > m_pimpl; // // catalog name handler: // static std::string& get_catalog_name_inst(); #ifdef BOOST_HAS_THREADS - static static_mutex& get_mutex_inst(); + static std::mutex& get_mutex_inst(); #endif }; template -boost::intmax_t cpp_regex_traits::toi(const charT*& first, const charT* last, int radix)const +std::intmax_t cpp_regex_traits::toi(const charT*& first, const charT* last, int radix)const { BOOST_REGEX_DETAIL_NS::parser_buf sbuf; // buffer for parsing numbers. std::basic_istream is(&sbuf); // stream for parsing numbers. @@ -1082,7 +1081,7 @@ boost::intmax_t cpp_regex_traits::toi(const charT*& first, const charT* l if(std::abs(radix) == 16) is >> std::hex; else if(std::abs(radix) == 8) is >> std::oct; else is >> std::dec; - boost::intmax_t val; + std::intmax_t val; if(is >> val) { first = first + ((last - first) - sbuf.in_avail()); @@ -1096,7 +1095,7 @@ template std::string cpp_regex_traits::catalog_name(const std::string& name) { #ifdef BOOST_HAS_THREADS - static_mutex::scoped_lock lk(get_mutex_inst()); + std::lock_guard lk(get_mutex_inst()); #endif std::string result(get_catalog_name_inst()); get_catalog_name_inst() = name; @@ -1114,7 +1113,7 @@ template std::string cpp_regex_traits::get_catalog_name() { #ifdef BOOST_HAS_THREADS - static_mutex::scoped_lock lk(get_mutex_inst()); + std::lock_guard lk(get_mutex_inst()); #endif std::string result(get_catalog_name_inst()); return result; @@ -1122,9 +1121,9 @@ std::string cpp_regex_traits::get_catalog_name() #ifdef BOOST_HAS_THREADS template -static_mutex& cpp_regex_traits::get_mutex_inst() +std::mutex& cpp_regex_traits::get_mutex_inst() { - static static_mutex s_mutex = BOOST_STATIC_MUTEX_INIT; + static std::mutex s_mutex; return s_mutex; } #endif diff --git a/include/boost/regex/v5/iterator_category.hpp b/include/boost/regex/v5/iterator_category.hpp index 9e401423..412918b1 100644 --- a/include/boost/regex/v5/iterator_category.hpp +++ b/include/boost/regex/v5/iterator_category.hpp @@ -22,8 +22,7 @@ #define BOOST_REGEX_ITERATOR_CATEGORY_HPP #include -#include -#include +#include namespace boost{ namespace detail{ @@ -35,7 +34,7 @@ struct is_random_imp private: typedef typename std::iterator_traits::iterator_category cat; public: - BOOST_STATIC_CONSTANT(bool, value = (::boost::is_convertible::value)); + BOOST_STATIC_CONSTANT(bool, value = (std::is_convertible::value)); #else BOOST_STATIC_CONSTANT(bool, value = false); #endif @@ -73,7 +72,7 @@ template struct is_random_access_iterator { private: - typedef detail::is_random_imp_selector< ::boost::is_pointer::value> selector; + typedef detail::is_random_imp_selector< std::is_pointer::value> selector; typedef typename selector::template rebind bound_type; typedef typename bound_type::type answer; public: diff --git a/include/boost/regex/v5/match_flags.hpp b/include/boost/regex/v5/match_flags.hpp index a2cd307f..f750351d 100644 --- a/include/boost/regex/v5/match_flags.hpp +++ b/include/boost/regex/v5/match_flags.hpp @@ -20,7 +20,7 @@ #define BOOST_REGEX_V5_MATCH_FLAGS #ifdef __cplusplus -# include +# include #endif #ifdef __cplusplus @@ -97,13 +97,13 @@ typedef match_flags match_flag_type; #ifdef __cplusplus inline match_flags operator&(match_flags m1, match_flags m2) -{ return static_cast(static_cast(m1) & static_cast(m2)); } +{ return static_cast(static_cast(m1) & static_cast(m2)); } inline match_flags operator|(match_flags m1, match_flags m2) -{ return static_cast(static_cast(m1) | static_cast(m2)); } +{ return static_cast(static_cast(m1) | static_cast(m2)); } inline match_flags operator^(match_flags m1, match_flags m2) -{ return static_cast(static_cast(m1) ^ static_cast(m2)); } +{ return static_cast(static_cast(m1) ^ static_cast(m2)); } inline match_flags operator~(match_flags m1) -{ return static_cast(~static_cast(m1)); } +{ return static_cast(~static_cast(m1)); } inline match_flags& operator&=(match_flags& m1, match_flags m2) { m1 = m1&m2; return m1; } inline match_flags& operator|=(match_flags& m1, match_flags m2) diff --git a/include/boost/regex/v5/match_results.hpp b/include/boost/regex/v5/match_results.hpp index a8984ce2..d85641ac 100644 --- a/include/boost/regex/v5/match_results.hpp +++ b/include/boost/regex/v5/match_results.hpp @@ -167,7 +167,7 @@ public: const sub_match& s = m_subs[sub]; if(s.matched || (sub == 2)) { - return ::boost::BOOST_REGEX_DETAIL_NS::distance((BidiIterator)(m_base), (BidiIterator)(s.first)); + return std::distance((BidiIterator)(m_base), (BidiIterator)(s.first)); } } return ~static_cast(0); @@ -474,7 +474,7 @@ public: // private access functions: void BOOST_REGEX_CALL set_second(BidiIterator i) { - BOOST_ASSERT(m_subs.size() > 2); + BOOST_REGEX_ASSERT(m_subs.size() > 2); m_subs[2].second = i; m_subs[2].matched = true; m_subs[0].first = i; @@ -490,7 +490,7 @@ public: if(pos) m_last_closed_paren = static_cast(pos); pos += 2; - BOOST_ASSERT(m_subs.size() > pos); + BOOST_REGEX_ASSERT(m_subs.size() > pos); m_subs[pos].second = i; m_subs[pos].matched = m; if((pos == 2) && !escape_k) @@ -531,7 +531,7 @@ public: } void BOOST_REGEX_CALL set_first(BidiIterator i) { - BOOST_ASSERT(m_subs.size() > 2); + BOOST_REGEX_ASSERT(m_subs.size() > 2); // set up prefix: m_subs[1].second = i; m_subs[1].matched = (m_subs[1].first != i); @@ -546,7 +546,7 @@ public: } void BOOST_REGEX_CALL set_first(BidiIterator i, size_type pos, bool escape_k = false) { - BOOST_ASSERT(pos+2 < m_subs.size()); + BOOST_REGEX_ASSERT(pos+2 < m_subs.size()); if(pos || escape_k) { m_subs[pos+2].first = i; @@ -561,7 +561,7 @@ public: } void BOOST_REGEX_CALL maybe_assign(const match_results& m); - void BOOST_REGEX_CALL set_named_subs(boost::shared_ptr subs) + void BOOST_REGEX_CALL set_named_subs(std::shared_ptr subs) { m_named_subs = subs; } @@ -580,7 +580,7 @@ private: vector_type m_subs; // subexpressions BidiIterator m_base; // where the search started from sub_match m_null; // a null match - boost::shared_ptr m_named_subs; // Shared copy of named subs in the regex object + std::shared_ptr m_named_subs; // Shared copy of named subs in the regex object int m_last_closed_paren; // Last ) to be seen - used for formatting bool m_is_singular; // True if our stored iterators are singular }; @@ -648,17 +648,17 @@ void BOOST_REGEX_CALL match_results::maybe_assign(const // p1 better than p2, and no need to calculate distances: return; } - base1 = ::boost::BOOST_REGEX_DETAIL_NS::distance(l_base, p1->first); - base2 = ::boost::BOOST_REGEX_DETAIL_NS::distance(l_base, p2->first); - BOOST_ASSERT(base1 >= 0); - BOOST_ASSERT(base2 >= 0); + base1 = std::distance(l_base, p1->first); + base2 = std::distance(l_base, p2->first); + BOOST_REGEX_ASSERT(base1 >= 0); + BOOST_REGEX_ASSERT(base2 >= 0); if(base1 < base2) return; if(base2 < base1) break; - len1 = ::boost::BOOST_REGEX_DETAIL_NS::distance((BidiIterator)p1->first, (BidiIterator)p1->second); - len2 = ::boost::BOOST_REGEX_DETAIL_NS::distance((BidiIterator)p2->first, (BidiIterator)p2->second); - BOOST_ASSERT(len1 >= 0); - BOOST_ASSERT(len2 >= 0); + len1 = std::distance((BidiIterator)p1->first, (BidiIterator)p1->second); + len2 = std::distance((BidiIterator)p2->first, (BidiIterator)p2->second); + BOOST_REGEX_ASSERT(len1 >= 0); + BOOST_REGEX_ASSERT(len2 >= 0); if((len1 != len2) || ((p1->matched == false) && (p2->matched == true))) break; if((p1->matched == true) && (p2->matched == false)) diff --git a/include/boost/regex/v5/mem_block_cache.hpp b/include/boost/regex/v5/mem_block_cache.hpp index 09e6ba4f..2e558b1a 100644 --- a/include/boost/regex/v5/mem_block_cache.hpp +++ b/include/boost/regex/v5/mem_block_cache.hpp @@ -20,7 +20,7 @@ #include #ifdef BOOST_HAS_THREADS -#include +#include #endif #ifdef BOOST_HAS_ABI_HEADERS @@ -107,7 +107,7 @@ struct mem_block_cache void* get() { #ifdef BOOST_HAS_THREADS - boost::static_mutex::scoped_lock g(mut); + std::lock_guard g(mut); #endif if(next) { @@ -121,7 +121,7 @@ struct mem_block_cache void put(void* p) { #ifdef BOOST_HAS_THREADS - boost::static_mutex::scoped_lock g(mut); + std::lock_guard g(mut); #endif if(cached_blocks >= BOOST_REGEX_MAX_CACHE_BLOCKS) { diff --git a/include/boost/regex/v5/perl_matcher.hpp b/include/boost/regex/v5/perl_matcher.hpp index fc0b7b4a..77ae3c00 100644 --- a/include/boost/regex/v5/perl_matcher.hpp +++ b/include/boost/regex/v5/perl_matcher.hpp @@ -475,7 +475,7 @@ private: // final result structure to be filled in: match_results& m_result; // temporary result for POSIX matches: - scoped_ptr > m_temp_match; + std::unique_ptr > m_temp_match; // pointer to actual result structure to fill in: match_results* m_presult; // start of sequence being searched: diff --git a/include/boost/regex/v5/perl_matcher_common.hpp b/include/boost/regex/v5/perl_matcher_common.hpp index 637bc622..b4ddb23a 100644 --- a/include/boost/regex/v5/perl_matcher_common.hpp +++ b/include/boost/regex/v5/perl_matcher_common.hpp @@ -114,7 +114,7 @@ void perl_matcher::estimate_max_state_count(std // Calculate NS^2 first: // static const std::ptrdiff_t k = 100000; - std::ptrdiff_t dist = boost::BOOST_REGEX_DETAIL_NS::distance(base, last); + std::ptrdiff_t dist = std::distance(base, last); if(dist == 0) dist = 1; std::ptrdiff_t states = re.size(); @@ -589,7 +589,7 @@ bool perl_matcher::match_backref() if(index >= hash_value_mask) { named_subexpressions::range_type r = re.get_data().equal_range(index); - BOOST_ASSERT(r.first != r.second); + BOOST_REGEX_ASSERT(r.first != r.second); do { index = r.first->index; @@ -698,7 +698,7 @@ bool perl_matcher::match_backstep() #endif if( ::boost::is_random_access_iterator::value) { - std::ptrdiff_t maxlen = ::boost::BOOST_REGEX_DETAIL_NS::distance(backstop, position); + std::ptrdiff_t maxlen = std::distance(backstop, position); if(maxlen < static_cast(pstate)->index) return false; std::advance(position, -static_cast(pstate)->index); diff --git a/include/boost/regex/v5/perl_matcher_non_recursive.hpp b/include/boost/regex/v5/perl_matcher_non_recursive.hpp index 49b565f6..73241b5d 100644 --- a/include/boost/regex/v5/perl_matcher_non_recursive.hpp +++ b/include/boost/regex/v5/perl_matcher_non_recursive.hpp @@ -111,7 +111,7 @@ struct save_state_init *end = reinterpret_cast(reinterpret_cast(*base)+BOOST_REGEX_BLOCKSIZE); --(*end); (void) new (*end)saved_state(0); - BOOST_ASSERT(*end > *base); + BOOST_REGEX_ASSERT(*end > *base); } ~save_state_init() { @@ -248,7 +248,7 @@ void perl_matcher::extend_stack() template inline void perl_matcher::push_matched_paren(int index, const sub_match& sub) { - //BOOST_ASSERT(index); + //BOOST_REGEX_ASSERT(index); saved_matched_paren* pmp = static_cast*>(m_backup_state); --pmp; if(pmp < m_stack_base) @@ -264,7 +264,7 @@ inline void perl_matcher::push_matched_paren(in template inline void perl_matcher::push_case_change(bool c) { - //BOOST_ASSERT(index); + //BOOST_REGEX_ASSERT(index); saved_change_case* pmp = static_cast(m_backup_state); --pmp; if(pmp < m_stack_base) @@ -492,7 +492,7 @@ bool perl_matcher::match_startmark() { // conditional expression: const re_alt* alt = static_cast(pstate->next.p); - BOOST_ASSERT(alt->type == syntax_element_alt); + BOOST_REGEX_ASSERT(alt->type == syntax_element_alt); pstate = alt->next.p; if(pstate->type == syntax_element_assert_backref) { @@ -503,7 +503,7 @@ bool perl_matcher::match_startmark() else { // zero width assertion, have to match this recursively: - BOOST_ASSERT(pstate->type == syntax_element_startmark); + BOOST_REGEX_ASSERT(pstate->type == syntax_element_startmark); bool negated = static_cast(pstate)->index == -2; BidiIterator saved_position = position; const re_syntax_base* next_pstate = static_cast(pstate->next.p)->alt.p->next.p; @@ -543,7 +543,7 @@ bool perl_matcher::match_startmark() } default: { - BOOST_ASSERT(index > 0); + BOOST_REGEX_ASSERT(index > 0); if((m_match_flags & match_nosubs) == 0) { push_matched_paren(index, (*m_presult)[index]); @@ -754,7 +754,7 @@ bool perl_matcher::match_dot_repeat_fast() const re_repeat* rep = static_cast(pstate); bool greedy = (rep->greedy) && (!(m_match_flags & regex_constants::match_any) || m_independent); - std::size_t count = static_cast((std::min)(static_cast(::boost::BOOST_REGEX_DETAIL_NS::distance(position, last)), greedy ? rep->max : rep->min)); + std::size_t count = static_cast((std::min)(static_cast(std::distance(position, last)), greedy ? rep->max : rep->min)); if(rep->min > count) { position = last; @@ -794,7 +794,7 @@ bool perl_matcher::match_char_repeat() #pragma option push -w-8008 -w-8066 -w-8004 #endif const re_repeat* rep = static_cast(pstate); - BOOST_ASSERT(1 == static_cast(rep->next.p)->length); + BOOST_REGEX_ASSERT(1 == static_cast(rep->next.p)->length); const char_type what = *reinterpret_cast(static_cast(rep->next.p) + 1); std::size_t count = 0; // @@ -807,7 +807,7 @@ bool perl_matcher::match_char_repeat() BidiIterator end = position; // Move end forward by "desired", preferably without using distance or advance if we can // as these can be slow for some iterator types. - std::size_t len = (desired == (std::numeric_limits::max)()) ? 0u : ::boost::BOOST_REGEX_DETAIL_NS::distance(position, last); + std::size_t len = (desired == (std::numeric_limits::max)()) ? 0u : std::distance(position, last); if(desired >= len) end = last; else @@ -817,7 +817,7 @@ bool perl_matcher::match_char_repeat() { ++position; } - count = (unsigned)::boost::BOOST_REGEX_DETAIL_NS::distance(origin, position); + count = (unsigned)std::distance(origin, position); } else { @@ -881,7 +881,7 @@ bool perl_matcher::match_set_repeat() BidiIterator end = position; // Move end forward by "desired", preferably without using distance or advance if we can // as these can be slow for some iterator types. - std::size_t len = (desired == (std::numeric_limits::max)()) ? 0u : ::boost::BOOST_REGEX_DETAIL_NS::distance(position, last); + std::size_t len = (desired == (std::numeric_limits::max)()) ? 0u : std::distance(position, last); if(desired >= len) end = last; else @@ -891,7 +891,7 @@ bool perl_matcher::match_set_repeat() { ++position; } - count = (unsigned)::boost::BOOST_REGEX_DETAIL_NS::distance(origin, position); + count = (unsigned)std::distance(origin, position); } else { @@ -956,7 +956,7 @@ bool perl_matcher::match_long_set_repeat() BidiIterator end = position; // Move end forward by "desired", preferably without using distance or advance if we can // as these can be slow for some iterator types. - std::size_t len = (desired == (std::numeric_limits::max)()) ? 0u : ::boost::BOOST_REGEX_DETAIL_NS::distance(position, last); + std::size_t len = (desired == (std::numeric_limits::max)()) ? 0u : std::distance(position, last); if(desired >= len) end = last; else @@ -966,7 +966,7 @@ bool perl_matcher::match_long_set_repeat() { ++position; } - count = (unsigned)::boost::BOOST_REGEX_DETAIL_NS::distance(origin, position); + count = (unsigned)std::distance(origin, position); } else { @@ -1010,7 +1010,7 @@ bool perl_matcher::match_long_set_repeat() template bool perl_matcher::match_recursion() { - BOOST_ASSERT(pstate->type == syntax_element_recurse); + BOOST_REGEX_ASSERT(pstate->type == syntax_element_recurse); // // See if we've seen this recursion before at this location, if we have then // we need to prevent infinite recursion: @@ -1087,7 +1087,7 @@ bool perl_matcher::match_match() { if(!recursion_stack.empty()) { - BOOST_ASSERT(0 == recursion_stack.back().idx); + BOOST_REGEX_ASSERT(0 == recursion_stack.back().idx); pstate = recursion_stack.back().preturn_address; push_recursion(recursion_stack.back().idx, recursion_stack.back().preturn_address, m_presult, &recursion_stack.back().results); *m_presult = recursion_stack.back().results; @@ -1394,15 +1394,15 @@ bool perl_matcher::unwind_greedy_single_repeat( const re_repeat* rep = pmp->rep; std::size_t count = pmp->count; - BOOST_ASSERT(rep->next.p != 0); - BOOST_ASSERT(rep->alt.p != 0); + BOOST_REGEX_ASSERT(rep->next.p != 0); + BOOST_REGEX_ASSERT(rep->alt.p != 0); count -= rep->min; if((m_match_flags & match_partial) && (position == last)) m_has_partial_match = true; - BOOST_ASSERT(count); + BOOST_REGEX_ASSERT(count); position = pmp->last_position; // backtrack till we can skip out: @@ -1443,12 +1443,12 @@ bool perl_matcher::unwind_slow_dot_repeat(bool const re_repeat* rep = pmp->rep; std::size_t count = pmp->count; - BOOST_ASSERT(rep->type == syntax_element_dot_rep); - BOOST_ASSERT(rep->next.p != 0); - BOOST_ASSERT(rep->alt.p != 0); - BOOST_ASSERT(rep->next.p->type == syntax_element_wild); + BOOST_REGEX_ASSERT(rep->type == syntax_element_dot_rep); + BOOST_REGEX_ASSERT(rep->next.p != 0); + BOOST_REGEX_ASSERT(rep->alt.p != 0); + BOOST_REGEX_ASSERT(rep->next.p->type == syntax_element_wild); - BOOST_ASSERT(count < rep->max); + BOOST_REGEX_ASSERT(count < rep->max); pstate = rep->next.p; position = pmp->last_position; @@ -1508,7 +1508,7 @@ bool perl_matcher::unwind_fast_dot_repeat(bool const re_repeat* rep = pmp->rep; std::size_t count = pmp->count; - BOOST_ASSERT(count < rep->max); + BOOST_REGEX_ASSERT(count < rep->max); position = pmp->last_position; if(position != last) { @@ -1568,11 +1568,11 @@ bool perl_matcher::unwind_char_repeat(bool r) const char_type what = *reinterpret_cast(static_cast(pstate) + 1); position = pmp->last_position; - BOOST_ASSERT(rep->type == syntax_element_char_rep); - BOOST_ASSERT(rep->next.p != 0); - BOOST_ASSERT(rep->alt.p != 0); - BOOST_ASSERT(rep->next.p->type == syntax_element_literal); - BOOST_ASSERT(count < rep->max); + BOOST_REGEX_ASSERT(rep->type == syntax_element_char_rep); + BOOST_REGEX_ASSERT(rep->next.p != 0); + BOOST_REGEX_ASSERT(rep->alt.p != 0); + BOOST_REGEX_ASSERT(rep->next.p->type == syntax_element_literal); + BOOST_REGEX_ASSERT(count < rep->max); if(position != last) { @@ -1637,11 +1637,11 @@ bool perl_matcher::unwind_short_set_repeat(bool const unsigned char* map = static_cast(rep->next.p)->_map; position = pmp->last_position; - BOOST_ASSERT(rep->type == syntax_element_short_set_rep); - BOOST_ASSERT(rep->next.p != 0); - BOOST_ASSERT(rep->alt.p != 0); - BOOST_ASSERT(rep->next.p->type == syntax_element_set); - BOOST_ASSERT(count < rep->max); + BOOST_REGEX_ASSERT(rep->type == syntax_element_short_set_rep); + BOOST_REGEX_ASSERT(rep->next.p != 0); + BOOST_REGEX_ASSERT(rep->alt.p != 0); + BOOST_REGEX_ASSERT(rep->next.p->type == syntax_element_set); + BOOST_REGEX_ASSERT(count < rep->max); if(position != last) { @@ -1707,11 +1707,11 @@ bool perl_matcher::unwind_long_set_repeat(bool const re_set_long* set = static_cast*>(pstate); position = pmp->last_position; - BOOST_ASSERT(rep->type == syntax_element_long_set_rep); - BOOST_ASSERT(rep->next.p != 0); - BOOST_ASSERT(rep->alt.p != 0); - BOOST_ASSERT(rep->next.p->type == syntax_element_long_set); - BOOST_ASSERT(count < rep->max); + BOOST_REGEX_ASSERT(rep->type == syntax_element_long_set_rep); + BOOST_REGEX_ASSERT(rep->next.p != 0); + BOOST_REGEX_ASSERT(rep->alt.p != 0); + BOOST_REGEX_ASSERT(rep->next.p->type == syntax_element_long_set); + BOOST_REGEX_ASSERT(count < rep->max); if(position != last) { diff --git a/include/boost/regex/v5/regex_format.hpp b/include/boost/regex/v5/regex_format.hpp index 33c4a5cb..c913aded 100644 --- a/include/boost/regex/v5/regex_format.hpp +++ b/include/boost/regex/v5/regex_format.hpp @@ -21,20 +21,8 @@ #ifndef BOOST_REGEX_FORMAT_HPP #define BOOST_REGEX_FORMAT_HPP -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef BOOST_NO_SFINAE -#include -#endif -#include +#include +#include namespace boost{ @@ -127,34 +115,34 @@ private: void format_until_scope_end(); bool handle_perl_verb(bool have_brace); - inline typename Results::value_type const& get_named_sub(ForwardIter i, ForwardIter j, const mpl::false_&) + inline typename Results::value_type const& get_named_sub(ForwardIter i, ForwardIter j, const std::integral_constant&) { std::vector v(i, j); return (i != j) ? this->m_results.named_subexpression(&v[0], &v[0] + v.size()) : this->m_results.named_subexpression(static_cast(0), static_cast(0)); } - inline typename Results::value_type const& get_named_sub(ForwardIter i, ForwardIter j, const mpl::true_&) + inline typename Results::value_type const& get_named_sub(ForwardIter i, ForwardIter j, const std::integral_constant&) { return this->m_results.named_subexpression(i, j); } inline typename Results::value_type const& get_named_sub(ForwardIter i, ForwardIter j) { - typedef typename boost::is_convertible::type tag_type; + typedef typename std::is_convertible::type tag_type; return get_named_sub(i, j, tag_type()); } - inline int get_named_sub_index(ForwardIter i, ForwardIter j, const mpl::false_&) + inline int get_named_sub_index(ForwardIter i, ForwardIter j, const std::integral_constant&) { std::vector v(i, j); return (i != j) ? this->m_results.named_subexpression_index(&v[0], &v[0] + v.size()) : this->m_results.named_subexpression_index(static_cast(0), static_cast(0)); } - inline int get_named_sub_index(ForwardIter i, ForwardIter j, const mpl::true_&) + inline int get_named_sub_index(ForwardIter i, ForwardIter j, const std::integral_constant&) { return this->m_results.named_subexpression_index(i, j); } inline int get_named_sub_index(ForwardIter i, ForwardIter j) { - typedef typename boost::is_convertible::type tag_type; + typedef typename std::is_convertible::type tag_type; return get_named_sub_index(i, j, tag_type()); } #ifdef BOOST_MSVC @@ -162,7 +150,7 @@ private: #pragma warning(push) #pragma warning(disable:4244) #endif - inline int toi(ForwardIter& i, ForwardIter j, int base, const boost::mpl::false_&) + inline int toi(ForwardIter& i, ForwardIter j, int base, const std::integral_constant&) { if(i != j) { @@ -178,7 +166,7 @@ private: #ifdef BOOST_MSVC #pragma warning(pop) #endif - inline int toi(ForwardIter& i, ForwardIter j, int base, const boost::mpl::true_&) + inline int toi(ForwardIter& i, ForwardIter j, int base, const std::integral_constant&) { return m_traits.toi(i, j, base); } @@ -187,9 +175,9 @@ private: #if defined(_MSC_VER) && defined(__INTEL_COMPILER) && ((__INTEL_COMPILER == 9999) || (__INTEL_COMPILER == 1210)) // Workaround for Intel support issue #656654. // See also https://svn.boost.org/trac/boost/ticket/6359 - return toi(i, j, base, mpl::false_()); + return toi(i, j, base, std::integral_constant()); #else - typedef typename boost::is_convertible::type tag_type; + typedef typename std::is_convertible::type tag_type; return toi(i, j, base, tag_type()); #endif } @@ -251,7 +239,7 @@ void basic_regex_formatter::format m_have_conditional = have_conditional; if(m_position == m_end) return; - BOOST_ASSERT(*m_position == static_cast(')')); + BOOST_REGEX_ASSERT(*m_position == static_cast(')')); ++m_position; // skip the closing ')' break; } @@ -307,7 +295,7 @@ void basic_regex_formatter::format // On entry *m_position points to a '$' character // output the information that goes with it: // - BOOST_ASSERT(*m_position == '$'); + BOOST_REGEX_ASSERT(*m_position == '$'); // // see if this is a trailing '$': // @@ -366,7 +354,7 @@ void basic_regex_formatter::format default: // see if we have a number: { - std::ptrdiff_t len = ::boost::BOOST_REGEX_DETAIL_NS::distance(m_position, m_end); + std::ptrdiff_t len = std::distance(m_position, m_end); //len = (std::min)(static_cast(2), len); int v = this->toi(m_position, m_position + len, 10); if((v < 0) || (have_brace && ((m_position == m_end) || (*m_position != '}')))) @@ -577,7 +565,7 @@ void basic_regex_formatter::format } else { - std::ptrdiff_t len = ::boost::BOOST_REGEX_DETAIL_NS::distance(m_position, m_end); + std::ptrdiff_t len = std::distance(m_position, m_end); len = (std::min)(static_cast(2), len); int val = this->toi(m_position, m_position + len, 16); if(val < 0) @@ -641,7 +629,7 @@ void basic_regex_formatter::format break; } // see if we have a \n sed style backreference: - std::ptrdiff_t len = ::boost::BOOST_REGEX_DETAIL_NS::distance(m_position, m_end); + std::ptrdiff_t len = std::distance(m_position, m_end); len = (std::min)(static_cast(1), len); int v = this->toi(m_position, m_position+len, 10); if((v > 0) || ((v == 0) && (m_flags & ::boost::regex_constants::format_sed))) @@ -653,10 +641,10 @@ void basic_regex_formatter::format { // octal ecape sequence: --m_position; - len = ::boost::BOOST_REGEX_DETAIL_NS::distance(m_position, m_end); + len = std::distance(m_position, m_end); len = (std::min)(static_cast(4), len); v = this->toi(m_position, m_position + len, 8); - BOOST_ASSERT(v >= 0); + BOOST_REGEX_ASSERT(v >= 0); put(static_cast(v)); break; } @@ -700,7 +688,7 @@ void basic_regex_formatter::format } else { - std::ptrdiff_t len = ::boost::BOOST_REGEX_DETAIL_NS::distance(m_position, m_end); + std::ptrdiff_t len = std::distance(m_position, m_end); len = (std::min)(static_cast(2), len); v = this->toi(m_position, m_position + len, 10); } @@ -837,7 +825,7 @@ OutputIterator regex_format_imp(OutputIterator out, { if(flags & regex_constants::format_literal) { - return BOOST_REGEX_DETAIL_NS::copy(p1, p2, out); + return std::copy(p1, p2, out); } BOOST_REGEX_DETAIL_NS::basic_regex_formatter< @@ -847,9 +835,17 @@ OutputIterator regex_format_imp(OutputIterator out, return f.format(p1, p2, flags); } -#ifndef BOOST_NO_SFINAE +template +struct has_const_iterator +{ + template + static typename U::const_iterator tester(U*); + static char tester(...); -BOOST_MPL_HAS_XXX_TRAIT_DEF(const_iterator) + static T* get(); + + static const bool value = sizeof(tester(get())) != sizeof(char); +}; struct any_type { @@ -891,7 +887,7 @@ struct unary_binary_ternary operator ternary_fun(); }; -template::value> +template::value> struct formatter_wrapper : Formatter , unary_binary_ternary @@ -913,6 +909,22 @@ struct formatter_wrapper operator Formatter *(); }; +template +struct do_unwrap_reference +{ + typedef T type; +}; +template +struct do_unwrap_reference > +{ + typedef T type; +}; + +template +T& do_unwrap_ref(T& r) { return r; } +template +T& do_unwrap_ref(std::reference_wrapper const& r) { return r.get(); } + template struct format_traits_imp { @@ -920,8 +932,8 @@ private: // // F must be a pointer, a function, or a class with a function call operator: // - BOOST_STATIC_ASSERT((::boost::is_pointer::value || ::boost::is_function::value || ::boost::is_class::value)); - static formatter_wrapper::type> f; + BOOST_STATIC_ASSERT((::std::is_pointer::value || ::std::is_function::value || ::std::is_class::value)); + static formatter_wrapper::type> f; static M m; static O out; static boost::regex_constants::match_flag_type flags; @@ -934,7 +946,7 @@ struct format_traits { public: // - // Type is mpl::int_ where N is one of: + // Type is std::integral_constant where N is one of: // // 0 : F is a pointer to a presumably null-terminated string. // 1 : F is a character-container such as a std::string. @@ -942,46 +954,22 @@ public: // 3 : F is a Binary Functor. // 4 : F is a Ternary Functor. // - typedef typename boost::mpl::if_< - boost::mpl::and_, boost::mpl::not_::type> > >, - boost::mpl::int_<0>, - typename boost::mpl::if_< - has_const_iterator, - boost::mpl::int_<1>, - boost::mpl::int_::value> + typedef typename std::conditional< + std::is_pointer::value && !std::is_function::type>::value, + std::integral_constant, + typename std::conditional< + has_const_iterator::value, + std::integral_constant, + std::integral_constant::value> >::type >::type type; // // This static assertion will fail if the functor passed does not accept // the same type of arguments passed. // - BOOST_STATIC_ASSERT( boost::is_class::value && !has_const_iterator::value ? (type::value > 1) : true); + BOOST_STATIC_ASSERT( std::is_class::value && !has_const_iterator::value ? (type::value > 1) : true); }; -#else // BOOST_NO_SFINAE - -template -struct format_traits -{ -public: - // - // Type is mpl::int_ where N is one of: - // - // 0 : F is a pointer to a presumably null-terminated string. - // 1 : F is a character-container such as a std::string. - // - // Other options such as F being a Functor are not supported without - // SFINAE support. - // - typedef typename boost::mpl::if_< - boost::is_pointer, - boost::mpl::int_<0>, - boost::mpl::int_<1> - >::type type; -}; - -#endif // BOOST_NO_SFINAE - template struct format_functor3 { @@ -989,7 +977,7 @@ struct format_functor3 template OutputIter operator()(const Match& m, OutputIter i, boost::regex_constants::match_flag_type f) { - return boost::unwrap_ref(func)(m, i, f); + return do_unwrap_ref(func)(m, i, f); } template OutputIter operator()(const Match& m, OutputIter i, boost::regex_constants::match_flag_type f, const Traits&) @@ -1009,7 +997,7 @@ struct format_functor2 template OutputIter operator()(const Match& m, OutputIter i, boost::regex_constants::match_flag_type /*f*/) { - return boost::unwrap_ref(func)(m, i); + return do_unwrap_ref(func)(m, i); } template OutputIter operator()(const Match& m, OutputIter i, boost::regex_constants::match_flag_type f, const Traits&) @@ -1030,7 +1018,7 @@ struct format_functor1 template OutputIter do_format_string(const S& s, OutputIter i) { - return BOOST_REGEX_DETAIL_NS::copy(s.begin(), s.end(), i); + return std::copy(s.begin(), s.end(), i); } template inline OutputIter do_format_string(const S* s, OutputIter i) @@ -1046,7 +1034,7 @@ struct format_functor1 template OutputIter operator()(const Match& m, OutputIter i, boost::regex_constants::match_flag_type /*f*/) { - return do_format_string(boost::unwrap_ref(func)(m), i); + return do_format_string(do_unwrap_ref(func)(m), i); } template OutputIter operator()(const Match& m, OutputIter i, boost::regex_constants::match_flag_type f, const Traits&) @@ -1099,16 +1087,16 @@ template ::type tag; - typedef typename boost::remove_cv< typename boost::remove_pointer::type>::type maybe_char_type; + typedef typename std::remove_cv< typename std::remove_pointer::type>::type maybe_char_type; - typedef typename mpl::if_< - ::boost::is_same >, format_functor_c_string, - typename mpl::if_< - ::boost::is_same >, format_functor_container, - typename mpl::if_< - ::boost::is_same >, format_functor1, - typename mpl::if_< - ::boost::is_same >, format_functor2, + typedef typename std::conditional< + tag::value == 0, format_functor_c_string, + typename std::conditional< + tag::value == 1, format_functor_container, + typename std::conditional< + tag::value == 2, format_functor1, + typename std::conditional< + tag::value == 3, format_functor2, format_functor3 >::type >::type diff --git a/include/boost/regex/v5/regex_iterator.hpp b/include/boost/regex/v5/regex_iterator.hpp index bccbd7f7..317ff1f4 100644 --- a/include/boost/regex/v5/regex_iterator.hpp +++ b/include/boost/regex/v5/regex_iterator.hpp @@ -19,7 +19,7 @@ #ifndef BOOST_REGEX_V5_REGEX_ITERATOR_HPP #define BOOST_REGEX_V5_REGEX_ITERATOR_HPP -#include +#include namespace boost{ @@ -90,7 +90,7 @@ class regex_iterator { private: typedef regex_iterator_implementation impl; - typedef shared_ptr pimpl; + typedef std::shared_ptr pimpl; public: typedef basic_regex regex_type; typedef match_results value_type; diff --git a/include/boost/regex/v5/regex_raw_buffer.hpp b/include/boost/regex/v5/regex_raw_buffer.hpp index c73a3e90..ac27e1a2 100644 --- a/include/boost/regex/v5/regex_raw_buffer.hpp +++ b/include/boost/regex/v5/regex_raw_buffer.hpp @@ -158,7 +158,7 @@ public: void* BOOST_REGEX_CALL insert(size_type pos, size_type n) { - BOOST_ASSERT(pos <= size_type(end - start)); + BOOST_REGEX_ASSERT(pos <= size_type(end - start)); if (size_type(last - end) < n) resize(n + (end - start)); void* result = start + pos; diff --git a/include/boost/regex/v5/regex_replace.hpp b/include/boost/regex/v5/regex_replace.hpp index 4cd7ddf7..c02cca6b 100644 --- a/include/boost/regex/v5/regex_replace.hpp +++ b/include/boost/regex/v5/regex_replace.hpp @@ -48,7 +48,7 @@ OutputIterator regex_replace(OutputIterator out, if(i == j) { if(!(flags & regex_constants::format_no_copy)) - out = BOOST_REGEX_DETAIL_NS::copy(first, last, out); + out = std::copy(first, last, out); } else { @@ -56,7 +56,7 @@ OutputIterator regex_replace(OutputIterator out, while(i != j) { if(!(flags & regex_constants::format_no_copy)) - out = BOOST_REGEX_DETAIL_NS::copy(i->prefix().first, i->prefix().second, out); + out = std::copy(i->prefix().first, i->prefix().second, out); out = i->format(out, fmt, flags, e); last_m = (*i)[0].second; if(flags & regex_constants::format_first_only) @@ -64,7 +64,7 @@ OutputIterator regex_replace(OutputIterator out, ++i; } if(!(flags & regex_constants::format_no_copy)) - out = BOOST_REGEX_DETAIL_NS::copy(last_m, last, out); + out = std::copy(last_m, last, out); } return out; } diff --git a/include/boost/regex/v5/regex_token_iterator.hpp b/include/boost/regex/v5/regex_token_iterator.hpp index 61eea711..77a71201 100644 --- a/include/boost/regex/v5/regex_token_iterator.hpp +++ b/include/boost/regex/v5/regex_token_iterator.hpp @@ -19,19 +19,7 @@ #ifndef BOOST_REGEX_V5_REGEX_TOKEN_ITERATOR_HPP #define BOOST_REGEX_V5_REGEX_TOKEN_ITERATOR_HPP -#include -#include -#if (BOOST_WORKAROUND(BOOST_BORLANDC, >= 0x560) && BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x570)))\ - || BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003)) -// -// Borland C++ Builder 6, and Visual C++ 6, -// can't cope with the array template constructor -// so we have a template member that will accept any type as -// argument, and then assert that is really is an array: -// -#include -#include -#endif +#include namespace boost{ @@ -170,7 +158,7 @@ class regex_token_iterator { private: typedef regex_token_iterator_implementation impl; - typedef shared_ptr pimpl; + typedef std::shared_ptr pimpl; public: typedef basic_regex regex_type; typedef sub_match value_type; diff --git a/include/boost/regex/v5/regex_traits.hpp b/include/boost/regex/v5/regex_traits.hpp index 8cfb46aa..e4b1279b 100644 --- a/include/boost/regex/v5/regex_traits.hpp +++ b/include/boost/regex/v5/regex_traits.hpp @@ -53,9 +53,6 @@ #include #endif -#include "boost/mpl/has_xxx.hpp" -#include - #ifdef BOOST_MSVC #pragma warning(push) #pragma warning(disable: 4103) @@ -83,15 +80,18 @@ struct regex_traits : public implementationT // required "standard" ones: // namespace BOOST_REGEX_DETAIL_NS{ -#if !BOOST_WORKAROUND(__HP_aCC, < 60000) -BOOST_MPL_HAS_XXX_TRAIT_DEF(boost_extensions_tag) -#else -template -struct has_boost_extensions_tag -{ - BOOST_STATIC_CONSTANT(bool, value = false); -}; -#endif + + template + struct has_boost_extensions_tag + { + template + static double checker(U*, typename U::boost_extensions_tag* = nullptr); + static char checker(...); + static T* get(); + + static const bool value = sizeof(checker(get())) > 1; + }; + template struct default_wrapper : public BaseT diff --git a/include/boost/regex/v5/regex_traits_defaults.hpp b/include/boost/regex/v5/regex_traits_defaults.hpp index 7eaf31f3..c5f318b9 100644 --- a/include/boost/regex/v5/regex_traits_defaults.hpp +++ b/include/boost/regex/v5/regex_traits_defaults.hpp @@ -40,8 +40,9 @@ #endif #include #include -#include -#include +#include +#include +#include #ifdef BOOST_NO_STDC_NAMESPACE namespace std{ @@ -558,9 +559,9 @@ inline regex_constants::escape_syntax_type BOOST_REGEX_CALL get_default_escape_s } // is charT c a combining character? -inline bool BOOST_REGEX_CALL is_combining_implementation(boost::uint_least16_t c) +inline bool BOOST_REGEX_CALL is_combining_implementation(std::uint_least16_t c) { - const boost::uint_least16_t combining_ranges[] = { 0x0300, 0x0361, + const std::uint_least16_t combining_ranges[] = { 0x0300, 0x0361, 0x0483, 0x0486, 0x0903, 0x0903, 0x093E, 0x0940, @@ -599,7 +600,7 @@ inline bool BOOST_REGEX_CALL is_combining_implementation(boost::uint_least16_t c 0xFE20, 0xFE23, 0xffff, 0xffff, }; - const boost::uint_least16_t* p = combining_ranges + 1; + const std::uint_least16_t* p = combining_ranges + 1; while (*p < c) p += 2; --p; if ((c >= *p) && (c <= *(p + 1))) @@ -661,9 +662,9 @@ inline bool is_separator(charT c) (c == static_cast('\n')) || (c == static_cast('\r')) || (c == static_cast('\f')) - || (static_cast(c) == 0x2028u) - || (static_cast(c) == 0x2029u) - || (static_cast(c) == 0x85u)); + || (static_cast(c) == 0x2028u) + || (static_cast(c) == 0x2029u) + || (static_cast(c) == 0x85u)); } template <> inline bool is_separator(char c) @@ -766,7 +767,7 @@ struct character_pointer_range // calling std::equal, but there is no other algorithm available: // not even a non-standard MS one. So forward to unchecked_equal // in the MS case. - return ((p2 - p1) == (r.p2 - r.p1)) && BOOST_REGEX_DETAIL_NS::equal(p1, p2, r.p1); + return ((p2 - p1) == (r.p2 - r.p1)) && std::equal(p1, p2, r.p1); } }; template @@ -917,14 +918,14 @@ int global_value(charT c) return -1; } template -boost::intmax_t global_toi(const charT*& p1, const charT* p2, int radix, const traits& t) +std::intmax_t global_toi(const charT*& p1, const charT* p2, int radix, const traits& t) { (void)t; // warning suppression - boost::intmax_t limit = (std::numeric_limits::max)() / radix; - boost::intmax_t next_value = t.value(*p1, radix); + std::intmax_t limit = (std::numeric_limits::max)() / radix; + std::intmax_t next_value = t.value(*p1, radix); if((p1 == p2) || (next_value < 0) || (next_value >= radix)) return -1; - boost::intmax_t result = 0; + std::intmax_t result = 0; while(p1 != p2) { next_value = t.value(*p1, radix); @@ -940,7 +941,7 @@ boost::intmax_t global_toi(const charT*& p1, const charT* p2, int radix, const t } template -inline typename boost::enable_if_c<(sizeof(charT) > 1), const charT*>::type get_escape_R_string() +inline typename std::enable_if<(sizeof(charT) > 1), const charT*>::type get_escape_R_string() { #ifdef BOOST_MSVC # pragma warning(push) @@ -962,7 +963,7 @@ inline typename boost::enable_if_c<(sizeof(charT) > 1), const charT*>::type get_ } template -inline typename boost::disable_if_c<(sizeof(charT) > 1), const charT*>::type get_escape_R_string() +inline typename std::enable_if<(sizeof(charT) == 1), const charT*>::type get_escape_R_string() { #ifdef BOOST_MSVC # pragma warning(push) diff --git a/include/boost/regex/v5/regex_workaround.hpp b/include/boost/regex/v5/regex_workaround.hpp index 35eafc25..3583050a 100644 --- a/include/boost/regex/v5/regex_workaround.hpp +++ b/include/boost/regex/v5/regex_workaround.hpp @@ -19,76 +19,22 @@ #ifndef BOOST_REGEX_WORKAROUND_HPP #define BOOST_REGEX_WORKAROUND_HPP -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include -#ifndef BOOST_NO_STD_LOCALE -# include -#endif +#include +#include +#include -#if defined(BOOST_NO_STDC_NAMESPACE) -namespace std{ - using ::sprintf; using ::strcpy; using ::strcat; using ::strlen; -} +#ifndef BOOST_REGEX_STANDALONE +#include +#include #endif -namespace boost{ namespace BOOST_REGEX_DETAIL_NS{ -#ifdef BOOST_NO_STD_DISTANCE -template -std::ptrdiff_t distance(const T& x, const T& y) -{ return y - x; } -#else -using std::distance; -#endif -}} - - #ifdef BOOST_REGEX_NO_BOOL # define BOOST_REGEX_MAKE_BOOL(x) static_cast((x) ? true : false) #else # define BOOST_REGEX_MAKE_BOOL(x) static_cast(x) #endif -/***************************************************************************** - * - * Fix broken namespace support: - * - ****************************************************************************/ - -#if defined(BOOST_NO_STDC_NAMESPACE) && defined(__cplusplus) - -namespace std{ - using ::ptrdiff_t; - using ::size_t; - using ::abs; - using ::memset; - using ::memcpy; -} - -#endif - /***************************************************************************** * * helper functions pointer_construct/pointer_destroy: @@ -126,67 +72,7 @@ inline void pointer_construct(T* p, const T& t) #ifdef __cplusplus namespace boost{ namespace BOOST_REGEX_DETAIL_NS{ -#if BOOST_WORKAROUND(BOOST_MSVC,>=1400) && BOOST_WORKAROUND(BOOST_MSVC, <1600) && defined(_CPPLIB_VER) && defined(BOOST_DINKUMWARE_STDLIB) && !(defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) - // - // MSVC 8 will either emit warnings or else refuse to compile - // code that makes perfectly legitimate use of std::copy, when - // the OutputIterator type is a user-defined class (apparently all user - // defined iterators are "unsafe"). This code works around that: - // - template - inline OutputIterator copy( - InputIterator first, - InputIterator last, - OutputIterator dest - ) - { - return stdext::unchecked_copy(first, last, dest); - } - template - inline bool equal( - InputIterator1 first, - InputIterator1 last, - InputIterator2 with - ) - { - return stdext::unchecked_equal(first, last, with); - } -#elif BOOST_WORKAROUND(BOOST_MSVC, > 1500) - // - // MSVC 10 will either emit warnings or else refuse to compile - // code that makes perfectly legitimate use of std::copy, when - // the OutputIterator type is a user-defined class (apparently all user - // defined iterators are "unsafe"). What's more Microsoft have removed their - // non-standard "unchecked" versions, even though their still in the MS - // documentation!! Work around this as best we can: - // - template - inline OutputIterator copy( - InputIterator first, - InputIterator last, - OutputIterator dest - ) - { - while(first != last) - *dest++ = *first++; - return dest; - } - template - inline bool equal( - InputIterator1 first, - InputIterator1 last, - InputIterator2 with - ) - { - while(first != last) - if(*first++ != *with++) return false; - return true; - } -#else - using std::copy; - using std::equal; -#endif -#if BOOST_WORKAROUND(BOOST_MSVC,>=1400) && defined(__STDC_WANT_SECURE_LIB__) && __STDC_WANT_SECURE_LIB__ +#if defined(BOOST_WORKAROUND) && BOOST_WORKAROUND(BOOST_MSVC,>=1400) && defined(__STDC_WANT_SECURE_LIB__) && __STDC_WANT_SECURE_LIB__ // use safe versions of strcpy etc: using ::strcpy_s; @@ -225,7 +111,11 @@ namespace boost{ namespace BOOST_REGEX_DETAIL_NS{ if(i) { std::overflow_error e("String buffer too small"); +#ifndef BOOST_REGEX_STANDALONE boost::throw_exception(e); +#else + throw e; +#endif } } diff --git a/include/boost/regex/v5/sub_match.hpp b/include/boost/regex/v5/sub_match.hpp index 9f0577aa..db666126 100644 --- a/include/boost/regex/v5/sub_match.hpp +++ b/include/boost/regex/v5/sub_match.hpp @@ -65,7 +65,7 @@ struct sub_match : public std::pair #endif difference_type BOOST_REGEX_CALL length()const { - difference_type n = matched ? ::boost::BOOST_REGEX_DETAIL_NS::distance((BidiIterator)this->first, (BidiIterator)this->second) : 0; + difference_type n = matched ? std::distance((BidiIterator)this->first, (BidiIterator)this->second) : 0; return n; } std::basic_string str()const @@ -73,7 +73,7 @@ struct sub_match : public std::pair std::basic_string result; if(matched) { - std::size_t len = ::boost::BOOST_REGEX_DETAIL_NS::distance((BidiIterator)this->first, (BidiIterator)this->second); + std::size_t len = std::distance((BidiIterator)this->first, (BidiIterator)this->second); result.reserve(len); BidiIterator i = this->first; while(i != this->second) @@ -132,7 +132,7 @@ struct sub_match : public std::pair } private: - mutable boost::scoped_ptr m_captures; + mutable std::unique_ptr m_captures; public: #endif diff --git a/include/boost/regex/v5/u32regex_iterator.hpp b/include/boost/regex/v5/u32regex_iterator.hpp index 66fc83f9..37448c1f 100644 --- a/include/boost/regex/v5/u32regex_iterator.hpp +++ b/include/boost/regex/v5/u32regex_iterator.hpp @@ -75,7 +75,7 @@ class u32regex_iterator { private: typedef u32regex_iterator_implementation impl; - typedef shared_ptr pimpl; + typedef std::shared_ptr pimpl; public: typedef u32regex regex_type; typedef match_results value_type; diff --git a/include/boost/regex/v5/u32regex_token_iterator.hpp b/include/boost/regex/v5/u32regex_token_iterator.hpp index 9562f525..ede7a76e 100644 --- a/include/boost/regex/v5/u32regex_token_iterator.hpp +++ b/include/boost/regex/v5/u32regex_token_iterator.hpp @@ -19,18 +19,6 @@ #ifndef BOOST_REGEX_V5_U32REGEX_TOKEN_ITERATOR_HPP #define BOOST_REGEX_V5_U32REGEX_TOKEN_ITERATOR_HPP -#if (BOOST_WORKAROUND(BOOST_BORLANDC, >= 0x560) && BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x570)))\ - || BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003)) -// -// Borland C++ Builder 6, and Visual C++ 6, -// can't cope with the array template constructor -// so we have a template member that will accept any type as -// argument, and then assert that is really is an array: -// -#include -#include -#endif - namespace boost{ #ifdef BOOST_HAS_ABI_HEADERS @@ -158,7 +146,7 @@ class u32regex_token_iterator { private: typedef u32regex_token_iterator_implementation impl; - typedef shared_ptr pimpl; + typedef std::shared_ptr pimpl; public: typedef u32regex regex_type; typedef sub_match value_type; diff --git a/include/boost/regex/v5/w32_regex_traits.hpp b/include/boost/regex/v5/w32_regex_traits.hpp index 5686cdf7..46e26660 100644 --- a/include/boost/regex/v5/w32_regex_traits.hpp +++ b/include/boost/regex/v5/w32_regex_traits.hpp @@ -28,13 +28,13 @@ #include #endif #ifdef BOOST_HAS_THREADS -#include +#include #endif #ifndef BOOST_REGEX_PRIMARY_TRANSFORM #include #endif #ifndef BOOST_REGEX_OBJECT_CACHE_HPP -#include +#include #endif #include @@ -76,7 +76,7 @@ namespace BOOST_REGEX_DETAIL_NS{ // start by typedeffing the types we'll need: // typedef ::boost::uint32_t lcid_type; // placeholder for LCID. -typedef ::boost::shared_ptr cat_type; // placeholder for dll HANDLE. +typedef ::std::shared_ptr cat_type; // placeholder for dll HANDLE. // // then add wrappers around the actual Win32 API's (ie implementation hiding): @@ -543,7 +543,7 @@ typename w32_regex_traits_implementation::char_class_type template -boost::shared_ptr > create_w32_regex_traits(::boost::BOOST_REGEX_DETAIL_NS::lcid_type l) +std::shared_ptr > create_w32_regex_traits(::boost::BOOST_REGEX_DETAIL_NS::lcid_type l) { // TODO: create a cache for previously constructed objects. return boost::object_cache< ::boost::BOOST_REGEX_DETAIL_NS::lcid_type, w32_regex_traits_implementation >::get(l, 5); @@ -663,14 +663,14 @@ public: static std::string get_catalog_name(); private: - boost::shared_ptr > m_pimpl; + std::shared_ptr > m_pimpl; // // catalog name handler: // static std::string& get_catalog_name_inst(); #ifdef BOOST_HAS_THREADS - static static_mutex& get_mutex_inst(); + static std::mutex& get_mutex_inst(); #endif }; @@ -678,7 +678,7 @@ template std::string w32_regex_traits::catalog_name(const std::string& name) { #ifdef BOOST_HAS_THREADS - static_mutex::scoped_lock lk(get_mutex_inst()); + std::lock_guard lk(get_mutex_inst()); #endif std::string result(get_catalog_name_inst()); get_catalog_name_inst() = name; @@ -696,7 +696,7 @@ template std::string w32_regex_traits::get_catalog_name() { #ifdef BOOST_HAS_THREADS - static_mutex::scoped_lock lk(get_mutex_inst()); + std::lock_guard lk(get_mutex_inst()); #endif std::string result(get_catalog_name_inst()); return result; @@ -704,9 +704,9 @@ std::string w32_regex_traits::get_catalog_name() #ifdef BOOST_HAS_THREADS template -static_mutex& w32_regex_traits::get_mutex_inst() +std::mutex& w32_regex_traits::get_mutex_inst() { - static static_mutex s_mutex = BOOST_STATIC_MUTEX_INIT; + static std::mutex s_mutex; return s_mutex; } #endif @@ -791,21 +791,21 @@ namespace BOOST_REGEX_DETAIL_NS { char_map[ii] = static_cast(ii); #ifndef BOOST_NO_ANSI_APIS int r = ::LCMapStringA(this->m_locale, LCMAP_LOWERCASE, char_map, 1 << CHAR_BIT, this->m_lower_map, 1 << CHAR_BIT); - BOOST_ASSERT(r != 0); + BOOST_REGEX_ASSERT(r != 0); #else UINT code_page = get_code_page_for_locale_id(this->m_locale); - BOOST_ASSERT(code_page != 0); + BOOST_REGEX_ASSERT(code_page != 0); WCHAR wide_char_map[1 << CHAR_BIT]; int conv_r = ::MultiByteToWideChar(code_page, 0, char_map, 1 << CHAR_BIT, wide_char_map, 1 << CHAR_BIT); - BOOST_ASSERT(conv_r != 0); + BOOST_REGEX_ASSERT(conv_r != 0); WCHAR wide_lower_map[1 << CHAR_BIT]; int r = ::LCMapStringW(this->m_locale, LCMAP_LOWERCASE, wide_char_map, 1 << CHAR_BIT, wide_lower_map, 1 << CHAR_BIT); - BOOST_ASSERT(r != 0); + BOOST_REGEX_ASSERT(r != 0); conv_r = ::WideCharToMultiByte(code_page, 0, wide_lower_map, r, this->m_lower_map, 1 << CHAR_BIT, NULL, NULL); - BOOST_ASSERT(conv_r != 0); + BOOST_REGEX_ASSERT(conv_r != 0); #endif if (r < (1 << CHAR_BIT)) { @@ -820,7 +820,7 @@ namespace BOOST_REGEX_DETAIL_NS { #else r = ::GetStringTypeExW(this->m_locale, CT_CTYPE1, wide_char_map, 1 << CHAR_BIT, this->m_type_map); #endif - BOOST_ASSERT(0 != r); + BOOST_REGEX_ASSERT(0 != r); } inline lcid_type BOOST_REGEX_CALL w32_get_default_locale() diff --git a/src/wide_posix_api.cpp b/src/wide_posix_api.cpp index abd68c59..e7ecefd1 100644 --- a/src/wide_posix_api.cpp +++ b/src/wide_posix_api.cpp @@ -227,7 +227,7 @@ BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorW(int code, const regex_tW* std::size_t len = p.size(); if(len < buf_size) { - BOOST_REGEX_DETAIL_NS::copy(p.c_str(), p.c_str() + p.size() + 1, buf); + std::copy(p.c_str(), p.c_str() + p.size() + 1, buf); } return len + 1; } diff --git a/test/object_cache/object_cache_test.cpp b/test/object_cache/object_cache_test.cpp index 50d883be..6575ac99 100644 --- a/test/object_cache/object_cache_test.cpp +++ b/test/object_cache/object_cache_test.cpp @@ -15,7 +15,14 @@ * VERSION see * DESCRIPTION: Test code for a generic object cache. */ -#include +#include +#ifdef BOOST_REGEX_CXX03 +#include +#define SP_NS boost +#else +#include +#define SP_NS std +#endif #include #include "../test_macros.hpp" @@ -49,7 +56,7 @@ int cpp_main(int /*argc*/, char * /*argv*/[]) int i; for(i = 0; i < 20; ++i) { - boost::shared_ptr p = boost::object_cache::get(i, max_cache_size); + SP_NS::shared_ptr p = boost::object_cache::get(i, max_cache_size); BOOST_CHECK(p->value() == i); p = boost::object_cache::get(i, max_cache_size); BOOST_CHECK(p->value() == i); @@ -64,7 +71,7 @@ int cpp_main(int /*argc*/, char * /*argv*/[]) { for(i = 20 - max_cache_size; i < 20; ++i) { - boost::shared_ptr p = boost::object_cache::get(i, max_cache_size); + SP_NS::shared_ptr p = boost::object_cache::get(i, max_cache_size); BOOST_CHECK(p->value() == i); p = boost::object_cache::get(i, max_cache_size); BOOST_CHECK(p->value() == i); diff --git a/test/regress/test_icu.cpp b/test/regress/test_icu.cpp index 1ef9fa96..c831f375 100644 --- a/test/regress/test_icu.cpp +++ b/test/regress/test_icu.cpp @@ -86,7 +86,7 @@ void compare_result(const MR1& w1, const MR2& w2, boost::mpl::int_<2> const*) { BOOST_REGEX_TEST_ERROR("Matched mismatch in match_results class", UChar32); } - if((w1.position(i) != boost::BOOST_REGEX_DETAIL_NS::distance(iterator_type(w2.prefix().first), iterator_type(w2[i].first))) || (w1.length(i) != boost::BOOST_REGEX_DETAIL_NS::distance(iterator_type(w2[i].first), iterator_type(w2[i].second)))) + if((w1.position(i) != std::distance(iterator_type(w2.prefix().first), iterator_type(w2[i].first))) || (w1.length(i) != std::distance(iterator_type(w2[i].first), iterator_type(w2[i].second)))) { BOOST_REGEX_TEST_ERROR("Iterator mismatch in match_results class", UChar32); } @@ -106,7 +106,7 @@ void compare_result(const MR1& w1, const MR2& w2, boost::mpl::int_<2> const*) { BOOST_REGEX_TEST_ERROR("Matched mismatch in match_results class", UChar32); } - if ((w1.position("abc") != boost::BOOST_REGEX_DETAIL_NS::distance(iterator_type(w2.prefix().first), iterator_type(w2["abc"].first))) || (w1.length("abc") != boost::BOOST_REGEX_DETAIL_NS::distance(iterator_type(w2["abc"].first), iterator_type(w2["abc"].second)))) + if ((w1.position("abc") != std::distance(iterator_type(w2.prefix().first), iterator_type(w2["abc"].first))) || (w1.length("abc") != std::distance(iterator_type(w2["abc"].first), iterator_type(w2["abc"].second)))) { BOOST_REGEX_TEST_ERROR("Iterator mismatch in match_results class", UChar32); } @@ -121,7 +121,7 @@ void compare_result(const MR1& w1, const MR2& w2, boost::mpl::int_<2> const*) { BOOST_REGEX_TEST_ERROR("Matched mismatch in match_results class", UChar32); } - if ((w1.position("N") != boost::BOOST_REGEX_DETAIL_NS::distance(iterator_type(w2.prefix().first), iterator_type(w2["N"].first))) || (w1.length("N") != boost::BOOST_REGEX_DETAIL_NS::distance(iterator_type(w2["N"].first), iterator_type(w2["N"].second)))) + if ((w1.position("N") != std::distance(iterator_type(w2.prefix().first), iterator_type(w2["N"].first))) || (w1.length("N") != std::distance(iterator_type(w2["N"].first), iterator_type(w2["N"].second)))) { BOOST_REGEX_TEST_ERROR("Iterator mismatch in match_results class", UChar32); } @@ -150,7 +150,7 @@ void compare_result(const MR1& w1, const MR2& w2, boost::mpl::int_<1> const*) { BOOST_REGEX_TEST_ERROR("Matched mismatch in match_results class", UChar32); } - if((w1.position(i) != boost::BOOST_REGEX_DETAIL_NS::distance(iterator_type(w2.prefix().first), iterator_type(w2[i].first))) || (w1.length(i) != boost::BOOST_REGEX_DETAIL_NS::distance(iterator_type(w2[i].first), iterator_type(w2[i].second)))) + if((w1.position(i) != std::distance(iterator_type(w2.prefix().first), iterator_type(w2[i].first))) || (w1.length(i) != std::distance(iterator_type(w2[i].first), iterator_type(w2[i].second)))) { BOOST_REGEX_TEST_ERROR("Iterator mismatch in match_results class", UChar32); } diff --git a/test/regress/test_mfc.cpp b/test/regress/test_mfc.cpp index 0d855cef..1dad08cf 100644 --- a/test/regress/test_mfc.cpp +++ b/test/regress/test_mfc.cpp @@ -170,21 +170,21 @@ void test_mfc(const char&, const test_regex_search_tag&) #pragma warning(push) #pragma warning(disable:4244) #endif - if(boost::BOOST_REGEX_DETAIL_NS::distance(s.GetString(), tstart2->first) != last_end2) + if(std::distance(s.GetString(), tstart2->first) != last_end2) { BOOST_REGEX_TEST_ERROR( "Error in location of start of field split, found: " - << boost::BOOST_REGEX_DETAIL_NS::distance(s.GetString(), tstart2->first) + << std::distance(s.GetString(), tstart2->first) << ", expected: " << last_end2 << ".", char); } int expected_end = static_cast(answer_table[0] < 0 ? s.GetLength() : answer_table[0]); - if(boost::BOOST_REGEX_DETAIL_NS::distance(s.GetString(), tstart2->second) != expected_end) + if(std::distance(s.GetString(), tstart2->second) != expected_end) { BOOST_REGEX_TEST_ERROR( "Error in location of end2 of field split, found: " - << boost::BOOST_REGEX_DETAIL_NS::distance(s.GetString(), tstart2->second) + << std::distance(s.GetString(), tstart2->second) << ", expected: " << expected_end << ".", char); @@ -348,21 +348,21 @@ void test_mfc(const wchar_t&, const test_regex_search_tag&) #pragma warning(push) #pragma warning(disable:4244) #endif - if(boost::BOOST_REGEX_DETAIL_NS::distance(s.GetString(), tstart2->first) != last_end2) + if(std::distance(s.GetString(), tstart2->first) != last_end2) { BOOST_REGEX_TEST_ERROR( "Error in location of start of field split, found: " - << boost::BOOST_REGEX_DETAIL_NS::distance(s.GetString(), tstart2->first) + << std::distance(s.GetString(), tstart2->first) << ", expected: " << last_end2 << ".", wchar_t); } int expected_end = static_cast(answer_table[0] < 0 ? s.GetLength() : answer_table[0]); - if(boost::BOOST_REGEX_DETAIL_NS::distance(s.GetString(), tstart2->second) != expected_end) + if(std::distance(s.GetString(), tstart2->second) != expected_end) { BOOST_REGEX_TEST_ERROR( "Error in location of end2 of field split, found: " - << boost::BOOST_REGEX_DETAIL_NS::distance(s.GetString(), tstart2->second) + << std::distance(s.GetString(), tstart2->second) << ", expected: " << expected_end << ".", wchar_t); diff --git a/test/regress/test_partial_match.hpp b/test/regress/test_partial_match.hpp index 19e45866..dddf9e23 100644 --- a/test/regress/test_partial_match.hpp +++ b/test/regress/test_partial_match.hpp @@ -47,18 +47,18 @@ void test_sub_match(const boost::sub_match& sub, Bidirect } else { - if(boost::BOOST_REGEX_DETAIL_NS::distance(base, sub.first) != answer_table[2*i]) + if(std::distance(base, sub.first) != answer_table[2*i]) { BOOST_REGEX_TEST_ERROR( "Error in start location of sub-expression " - << i << ", found " << boost::BOOST_REGEX_DETAIL_NS::distance(base, sub.first) + << i << ", found " << std::distance(base, sub.first) << ", expected " << answer_table[2*i] << ".", charT); } - if(boost::BOOST_REGEX_DETAIL_NS::distance(base, sub.second) != answer_table[1+ 2*i]) + if(std::distance(base, sub.second) != answer_table[1+ 2*i]) { BOOST_REGEX_TEST_ERROR( "Error in end location of sub-expression " - << i << ", found " << boost::BOOST_REGEX_DETAIL_NS::distance(base, sub.second) + << i << ", found " << std::distance(base, sub.second) << ", expected " << answer_table[1 + 2*i] << ".", charT); } } @@ -238,21 +238,21 @@ void test_regex_token_iterator(boost::basic_regex& r) #pragma warning(push) #pragma warning(disable:4244) #endif - if(boost::BOOST_REGEX_DETAIL_NS::distance(search_text.begin(), start2->first) != last_end2) + if(std::distance(search_text.begin(), start2->first) != last_end2) { BOOST_REGEX_TEST_ERROR( "Error in location of start of field split, found: " - << boost::BOOST_REGEX_DETAIL_NS::distance(search_text.begin(), start2->first) + << std::distance(search_text.begin(), start2->first) << ", expected: " << last_end2 << ".", charT); } int expected_end = static_cast(answer_table[0] < 0 ? search_text.size() : answer_table[0]); - if(boost::BOOST_REGEX_DETAIL_NS::distance(search_text.begin(), start2->second) != expected_end) + if(std::distance(search_text.begin(), start2->second) != expected_end) { BOOST_REGEX_TEST_ERROR( "Error in location of end2 of field split, found: " - << boost::BOOST_REGEX_DETAIL_NS::distance(search_text.begin(), start2->second) + << std::distance(search_text.begin(), start2->second) << ", expected: " << expected_end << ".", charT); diff --git a/test/regress/test_regex_search.hpp b/test/regress/test_regex_search.hpp index 16b1bf91..f0124727 100644 --- a/test/regress/test_regex_search.hpp +++ b/test/regress/test_regex_search.hpp @@ -55,18 +55,18 @@ void test_sub_match(const boost::sub_match& sub, Bidirect } else { - if(boost::BOOST_REGEX_DETAIL_NS::distance(base, sub.first) != answer_table[2*i]) + if(std::distance(base, sub.first) != answer_table[2*i]) { BOOST_REGEX_TEST_ERROR( "Error in start location of sub-expression " - << i << ", found " << boost::BOOST_REGEX_DETAIL_NS::distance(base, sub.first) + << i << ", found " << std::distance(base, sub.first) << ", expected " << answer_table[2*i] << ".", charT); } - if(boost::BOOST_REGEX_DETAIL_NS::distance(base, sub.second) != answer_table[1+ 2*i]) + if(std::distance(base, sub.second) != answer_table[1+ 2*i]) { BOOST_REGEX_TEST_ERROR( "Error in end location of sub-expression " - << i << ", found " << boost::BOOST_REGEX_DETAIL_NS::distance(base, sub.second) + << i << ", found " << std::distance(base, sub.second) << ", expected " << answer_table[1 + 2*i] << ".", charT); } } @@ -291,21 +291,21 @@ void test_regex_token_iterator(boost::basic_regex& r) #pragma warning(push) #pragma warning(disable:4244) #endif - if(boost::BOOST_REGEX_DETAIL_NS::distance(search_text.begin(), start2->first) != last_end2) + if(std::distance(search_text.begin(), start2->first) != last_end2) { BOOST_REGEX_TEST_ERROR( "Error in location of start of field split, found: " - << boost::BOOST_REGEX_DETAIL_NS::distance(search_text.begin(), start2->first) + << std::distance(search_text.begin(), start2->first) << ", expected: " << last_end2 << ".", charT); } int expected_end = static_cast(answer_table[0] < 0 ? search_text.size() : answer_table[0]); - if(boost::BOOST_REGEX_DETAIL_NS::distance(search_text.begin(), start2->second) != expected_end) + if(std::distance(search_text.begin(), start2->second) != expected_end) { BOOST_REGEX_TEST_ERROR( "Error in location of end2 of field split, found: " - << boost::BOOST_REGEX_DETAIL_NS::distance(search_text.begin(), start2->second) + << std::distance(search_text.begin(), start2->second) << ", expected: " << expected_end << ".", charT); @@ -350,21 +350,21 @@ void test_regex_token_iterator(boost::basic_regex& r) #pragma warning(push) #pragma warning(disable:4244) #endif - if(boost::BOOST_REGEX_DETAIL_NS::distance(search_text.begin(), start2->first) != last_end2) + if(std::distance(search_text.begin(), start2->first) != last_end2) { BOOST_REGEX_TEST_ERROR( "Error in location of start of field split, found: " - << boost::BOOST_REGEX_DETAIL_NS::distance(search_text.begin(), start2->first) + << std::distance(search_text.begin(), start2->first) << ", expected: " << last_end2 << ".", charT); } int expected_end = static_cast(answer_table[0] < 0 ? search_text.size() : answer_table[0]); - if(boost::BOOST_REGEX_DETAIL_NS::distance(search_text.begin(), start2->second) != expected_end) + if(std::distance(search_text.begin(), start2->second) != expected_end) { BOOST_REGEX_TEST_ERROR( "Error in location of end2 of field split, found: " - << boost::BOOST_REGEX_DETAIL_NS::distance(search_text.begin(), start2->second) + << std::distance(search_text.begin(), start2->second) << ", expected: " << expected_end << ".", charT);