Make the contents of regex.hpp all inline.

This commit is contained in:
jzmaddock
2020-11-29 19:10:05 +00:00
parent 9d64cf60ff
commit 49e8067b80
14 changed files with 146 additions and 259 deletions

View File

@ -69,6 +69,12 @@ struct mem_block_cache
}
::operator delete(ptr);
}
static mem_block_cache& instance()
{
static mem_block_cache block_cache = { { {nullptr} } };
return block_cache;
}
};
@ -129,11 +135,43 @@ struct mem_block_cache
++cached_blocks;
}
}
static mem_block_cache& instance()
{
#ifdef BOOST_HAS_THREADS
static mem_block_cache block_cache = { 0, 0, BOOST_STATIC_MUTEX_INIT, };
#else
static mem_block_cache block_cache = { 0, 0, };
#endif
return block_cache;
}
};
#endif
extern mem_block_cache block_cache;
#if BOOST_REGEX_MAX_CACHE_BLOCKS == 0
inline void* BOOST_REGEX_CALL get_mem_block()
{
return ::operator new(BOOST_REGEX_BLOCKSIZE);
}
inline void BOOST_REGEX_CALL put_mem_block(void* p)
{
::operator delete(p);
}
#else
inline void* BOOST_REGEX_CALL get_mem_block()
{
return mem_block_cache::instance().get();
}
inline void BOOST_REGEX_CALL put_mem_block(void* p)
{
mem_block_cache::instance().put(p);
}
#endif
}
} // namespace boost

View File

@ -45,7 +45,17 @@ namespace BOOST_REGEX_DETAIL_NS{
//
// error checking API:
//
BOOST_REGEX_DECL void BOOST_REGEX_CALL verify_options(boost::regex_constants::syntax_option_type ef, match_flag_type mf);
inline void BOOST_REGEX_CALL verify_options(boost::regex_constants::syntax_option_type, match_flag_type mf)
{
//
// can't mix match_extra with POSIX matching rules:
//
if ((mf & match_extra) && (mf & match_posix))
{
std::logic_error msg("Usage Error: Can't mix regular expression captures with POSIX matching rules");
throw_exception(msg);
}
}
//
// function can_start:
//

View File

@ -20,7 +20,7 @@
#ifndef BOOST_REGEX_V4_PERL_MATCHER_NON_RECURSIVE_HPP
#define BOOST_REGEX_V4_PERL_MATCHER_NON_RECURSIVE_HPP
#include <new>
#include <boost/regex/v4/mem_block_cache.hpp>
#ifdef BOOST_MSVC
#pragma warning(push)

View File

@ -31,6 +31,7 @@
#endif
#include <boost/regex/config.hpp>
#include <boost/cstdint.hpp>
#ifndef BOOST_REGEX_SYNTAX_TYPE_HPP
#include <boost/regex/v5/syntax_type.hpp>
@ -38,6 +39,7 @@
#ifndef BOOST_REGEX_ERROR_TYPE_HPP
#include <boost/regex/v5/error_type.hpp>
#endif
#include <boost/regex/v5/regex_workaround.hpp>
#include <boost/type_traits/make_unsigned.hpp>
#include <boost/utility/enable_if.hpp>