diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 15f74076..8c104347 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -201,7 +201,7 @@ jobs: - name: Test run: ../../../b2 toolset=${{ matrix.toolset }} cxxstd=${{ matrix.standard }} working-directory: ../boost-root/libs/regex/test - windows: + windows_gcc: runs-on: windows-latest defaults: run: @@ -211,8 +211,102 @@ jobs: strategy: fail-fast: false matrix: - toolset: [ gcc, msvc-14.0, msvc-14.2 ] - standard: [ 11, 14, 17 ] + toolset: [ gcc ] + standard: [ 11, 14, 17, 2a ] + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: '0' + - uses: mstachniuk/ci-skip@v1 + with: + commit-filter: '[skip ci];[ci skip];[CI SKIP];[SKIP CI];***CI SKIP***;***SKIP CI***;[apple];[Apple];[APPLE];[linux];[Linux];[LINUX]' + commit-filter-separator: ';' + fail-fast: true + - name: Checkout main boost + run: git clone -b develop --depth 1 https://github.com/boostorg/boost.git ../boost-root + - name: Update tools/boostdep + run: git submodule update --init tools/boostdep + working-directory: ../boost-root + - name: Copy files + run: xcopy /s /e /q %GITHUB_WORKSPACE% libs\regex + working-directory: ../boost-root + - name: Install deps + run: python tools/boostdep/depinst/depinst.py -I example -g "--jobs 3" regex + working-directory: ../boost-root + - name: Bootstrap + run: bootstrap + working-directory: ../boost-root + - name: Generate headers + run: b2 headers + working-directory: ../boost-root + - name: Config info install + run: ..\..\..\b2 config_info_travis_install %ARGS% + working-directory: ../boost-root/libs/config/test + - name: Config info + run: config_info_travis + working-directory: ../boost-root/libs/config/test + - name: Test + run: ..\..\..\b2 --hash %ARGS% + working-directory: ../boost-root/libs/regex/test + windows_msvc_14_0: + runs-on: windows-latest + defaults: + run: + shell: cmd + env: + ARGS: toolset=${{ matrix.toolset }} address-model=64 cxxstd=${{ matrix.standard }} + strategy: + fail-fast: false + matrix: + toolset: [ msvc-14.0 ] + standard: [ 14, 17 ] + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: '0' + - uses: mstachniuk/ci-skip@v1 + with: + commit-filter: '[skip ci];[ci skip];[CI SKIP];[SKIP CI];***CI SKIP***;***SKIP CI***;[apple];[Apple];[APPLE];[linux];[Linux];[LINUX]' + commit-filter-separator: ';' + fail-fast: true + - name: Checkout main boost + run: git clone -b develop --depth 1 https://github.com/boostorg/boost.git ../boost-root + - name: Update tools/boostdep + run: git submodule update --init tools/boostdep + working-directory: ../boost-root + - name: Copy files + run: xcopy /s /e /q %GITHUB_WORKSPACE% libs\regex + working-directory: ../boost-root + - name: Install deps + run: python tools/boostdep/depinst/depinst.py -I example -g "--jobs 3" regex + working-directory: ../boost-root + - name: Bootstrap + run: bootstrap + working-directory: ../boost-root + - name: Generate headers + run: b2 headers + working-directory: ../boost-root + - name: Config info install + run: ..\..\..\b2 config_info_travis_install %ARGS% + working-directory: ../boost-root/libs/config/test + - name: Config info + run: config_info_travis + working-directory: ../boost-root/libs/config/test + - name: Test + run: ..\..\..\b2 --hash %ARGS% + working-directory: ../boost-root/libs/regex/test + windows_msvc_14_2: + runs-on: windows-latest + defaults: + run: + shell: cmd + env: + ARGS: toolset=${{ matrix.toolset }} address-model=64 cxxstd=${{ matrix.standard }} + strategy: + fail-fast: false + matrix: + toolset: [ msvc-14.2 ] + standard: [ 14, 17, latest ] steps: - uses: actions/checkout@v2 with: diff --git a/include/boost/regex/pending/object_cache.hpp b/include/boost/regex/pending/object_cache.hpp index 7284a99e..0ddbdadf 100644 --- a/include/boost/regex/pending/object_cache.hpp +++ b/include/boost/regex/pending/object_cache.hpp @@ -21,167 +21,9 @@ #include #ifdef BOOST_REGEX_CXX03 -#include -#define BOOST_REGEX_SHARED_PTR_NS boost +#include #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 +#include #endif -namespace boost{ - -template -class object_cache -{ -public: - 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_REGEX_SHARED_PTR_NS::shared_ptr get(const Key& k, size_type l_max_cache_size); - -private: - static BOOST_REGEX_SHARED_PTR_NS::shared_ptr do_get(const Key& k, size_type l_max_cache_size); - - struct data - { - list_type cont; - map_type index; - }; - - // Needed by compilers not implementing the resolution to DR45. For reference, - // see http://www.open-std.org/JTC1/SC22/WG21/docs/cwg_defects.html#45. - friend struct data; -}; - -#ifdef BOOST_MSVC -#pragma warning(push) -#pragma warning(disable: 4702) -#endif -template -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) - { - return do_get(k, l_max_cache_size); - } - // - // what do we do if the lock fails? - // for now just throw, but we should never really get here... - // - ::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_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); -#endif -} -#ifdef BOOST_MSVC -#pragma warning(pop) -#endif - -template -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; - static object_data s_data; - - // - // see if the object is already in the cache: - // - map_iterator mpos = s_data.index.find(k); - if(mpos != s_data.index.end()) - { - // - // Eureka! - // We have a cached item, bump it up the list and return it: - // - if(--(s_data.cont.end()) != mpos->second) - { - // splice out the item we want to move: - list_type temp; - 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_REGEX_ASSERT(*(s_data.cont.back().second) == k); - // update index with new position: - mpos->second = --(s_data.cont.end()); - BOOST_REGEX_ASSERT(&(mpos->first) == mpos->second->second); - BOOST_REGEX_ASSERT(&(mpos->first) == s_data.cont.back().second); - } - return s_data.cont.back().first; - } - // - // if we get here then the item is not in the cache, - // so create it: - // - BOOST_REGEX_SHARED_PTR_NS::shared_ptr result(new Object(k)); - // - // Add it to the list, and index it: - // - s_data.cont.push_back(value_type(result, static_cast(0))); - 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_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) - { - // - // We have too many items in the list, so we need to start - // popping them off the back of the list, but only if they're - // being held uniquely by us: - // - list_iterator pos = s_data.cont.begin(); - list_iterator last = s_data.cont.end(); - while((pos != last) && (s > l_max_cache_size)) - { - if(pos->first.unique()) - { - list_iterator condemmed(pos); - ++pos; - // now remove the items from our containers, - // then order has to be as follows: - 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; - } - else - ++pos; - } - 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/v5/regex_iterator.hpp b/include/boost/regex/v5/regex_iterator.hpp index ba74e6de..b2e9d2ce 100644 --- a/include/boost/regex/v5/regex_iterator.hpp +++ b/include/boost/regex/v5/regex_iterator.hpp @@ -141,7 +141,7 @@ private: void cow() { // copy-on-write - if(pdata.get() && !pdata.unique()) + if(pdata.get() && (pdata.use_count() > 1)) { pdata.reset(new impl(*(pdata.get()))); } diff --git a/include/boost/regex/v5/regex_token_iterator.hpp b/include/boost/regex/v5/regex_token_iterator.hpp index 98f7d213..16832746 100644 --- a/include/boost/regex/v5/regex_token_iterator.hpp +++ b/include/boost/regex/v5/regex_token_iterator.hpp @@ -201,7 +201,7 @@ private: void cow() { // copy-on-write - if(pdata.get() && !pdata.unique()) + if(pdata.get() && (pdata.use_count() > 1)) { pdata.reset(new impl(*(pdata.get()))); } diff --git a/include/boost/regex/v5/u32regex_iterator.hpp b/include/boost/regex/v5/u32regex_iterator.hpp index 97d8e799..6677019a 100644 --- a/include/boost/regex/v5/u32regex_iterator.hpp +++ b/include/boost/regex/v5/u32regex_iterator.hpp @@ -133,7 +133,7 @@ private: void cow() { // copy-on-write - if(pdata.get() && !pdata.unique()) + if(pdata.get() && (pdata.use_count() > 1)) { pdata.reset(new impl(*(pdata.get()))); } diff --git a/include/boost/regex/v5/u32regex_token_iterator.hpp b/include/boost/regex/v5/u32regex_token_iterator.hpp index 0f3cad5b..3d303265 100644 --- a/include/boost/regex/v5/u32regex_token_iterator.hpp +++ b/include/boost/regex/v5/u32regex_token_iterator.hpp @@ -200,7 +200,7 @@ private: void cow() { // copy-on-write - if(pdata.get() && !pdata.unique()) + if(pdata.get() && (pdata.use_count() > 1)) { pdata.reset(new impl(*(pdata.get()))); }