Skip to content

Commit a49fd19

Browse files
damienbarkerjenkins
authored andcommitted
Merge branch 'QPR-13332' into 'master'
QPR-13332 replace boost regex with std regex Closes QPR-13332 See merge request qs/oreplus!2758
1 parent 37bdcea commit a49fd19

19 files changed

Lines changed: 68 additions & 94 deletions

File tree

App/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ get_library_name("OREData" ORED_LIB_NAME)
88
get_library_name("QuantExt" QLE_LIB_NAME)
99
set_ql_library_name()
1010

11-
find_package (Boost REQUIRED COMPONENTS regex date_time serialization filesystem timer OPTIONAL_COMPONENTS chrono)
11+
find_package (Boost REQUIRED COMPONENTS date_time serialization filesystem timer OPTIONAL_COMPONENTS chrono)
1212

1313
include_directories(${Boost_INCLUDE_DIRS})
1414
include_directories(${QUANTLIB_SOURCE_DIR})

App/ore.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@
4040
#include <ql/auto_link.hpp>
4141
#include <qle/auto_link.hpp>
4242
// Find the name of the correct boost library with which to link.
43-
#define BOOST_LIB_NAME boost_regex
44-
#include <boost/config/auto_link.hpp>
4543
#define BOOST_LIB_NAME boost_serialization
4644
#include <boost/config/auto_link.hpp>
4745
#define BOOST_LIB_NAME boost_date_time

ORE-SWIG/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ get_library_name("QuantExt" QLE_LIB_NAME)
3131
set_ql_library_name()
3232

3333
# To build the module, we moreover need Boost, Swig, Python
34-
set(BOOST_COMPONENT_LIST serialization date_time regex filesystem system timer thread log)
34+
set(BOOST_COMPONENT_LIST serialization date_time filesystem system timer thread log)
3535
if(ORE_USE_ZLIB)
3636
list(APPEND BOOST_COMPONENT_LIST iostreams)
3737
if(MSVC)

ORE-SWIG/OREAnalytics-SWIG/Java/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ include_directories(${PROJECT_SOURCE_DIR}/../../QuantExt-SWIG/SWIG)
5151
include_directories(${PROJECT_SOURCE_DIR}/../../OREData-SWIG/SWIG)
5252
include_directories(${PROJECT_SOURCE_DIR}/../../OREAnalytics-SWIG/SWIG)
5353

54-
find_package (Boost COMPONENTS serialization date_time regex filesystem system REQUIRED)
54+
find_package (Boost COMPONENTS serialization date_time filesystem system REQUIRED)
5555
include_directories(${Boost_INCLUDE_DIRS})
5656

5757
# specify library search path (update this when we build ORE with cmake)

OREAnalytics/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ if(ORE_USE_ZLIB)
1717
find_package(ZLIB REQUIRED)
1818
endif()
1919

20-
SET(COMPONENT_LIST date_time filesystem iostreams regex serialization system timer thread)
20+
SET(COMPONENT_LIST date_time filesystem iostreams serialization system timer thread)
2121
if (ORE_BUILD_TESTS)
2222
LIST(APPEND COMPONENT_LIST unit_test_framework)
2323
endif()

OREAnalytics/orea/app/reportwriter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,7 +1076,7 @@ void ReportWriter::writeMarketData(Report& report, const QuantLib::ext::shared_p
10761076

10771077
vector<std::regex> regexes;
10781078
regexes.reserve(regexStrs.size());
1079-
for (auto regexStr : regexStrs) {
1079+
for (const auto& regexStr : regexStrs) {
10801080
regexes.push_back(regex(regexStr));
10811081
}
10821082

@@ -1090,7 +1090,7 @@ void ReportWriter::writeMarketData(Report& report, const QuantLib::ext::shared_p
10901090

10911091
// This could be slow
10921092
for (const auto& regex : regexes) {
1093-
if (regex_match(mdName, regex)) {
1093+
if (std::regex_match(mdName, regex)) {
10941094
addMarketDatum(report, *md, loader->actualDate());
10951095
break;
10961096
}

OREAnalytics/orea/engine/marketriskreport.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
#include <orea/engine/sensitivityaggregator.hpp>
2727
#include <ql/math/matrixutilities/pseudosqrt.hpp>
2828
#include <ql/math/matrixutilities/symmetricschurdecomposition.hpp>
29-
#include <boost/regex.hpp>
29+
30+
#include <regex>
3031

3132
using namespace QuantLib;
3233
using namespace ore::data;
@@ -182,10 +183,10 @@ void MarketRiskReport::initialiseRiskGroups() {
182183

183184
// build portfolio filter, if given
184185
bool hasFilter = false;
185-
boost::regex filter;
186+
std::regex filter;
186187
if (portfolioFilter_ != "") {
187188
hasFilter = true;
188-
filter = boost::regex(portfolioFilter_);
189+
filter = std::regex(portfolioFilter_);
189190
LOG("Portfolio filter: " << portfolioFilter_);
190191
}
191192

@@ -196,7 +197,7 @@ void MarketRiskReport::initialiseRiskGroups() {
196197

197198
QL_REQUIRE(portfolio_, "No portfolio given");
198199
for (const auto& pId : portfolio_->portfolioIds()) {
199-
if (breakdown_ && (!hasFilter || boost::regex_match(pId, filter))) {
200+
if (breakdown_ && (!hasFilter || std::regex_match(pId, filter))) {
200201
auto tradeGroupP = QuantLib::ext::make_shared<TradeGroup>(pId);
201202
tradeGroups_->add(tradeGroupP);
202203
}
@@ -207,7 +208,7 @@ void MarketRiskReport::initialiseRiskGroups() {
207208
tradeIdGroups_[allStr].insert(make_pair(tradeId, pos));
208209
else {
209210
for (auto const& pId : trade->portfolioIds()) {
210-
if (!hasFilter || boost::regex_match(pId, filter)) {
211+
if (!hasFilter || std::regex_match(pId, filter)) {
211212
tradeIdGroups_[allStr].insert(make_pair(tradeId, pos));
212213
if (breakdown_)
213214
tradeIdGroups_[pId].insert(make_pair(tradeId, pos));

OREAnalytics/orea/engine/saccr.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,10 @@
5959
#include <ql/utilities/dataparsers.hpp>
6060
#include <ql/tuple.hpp>
6161

62-
#include <boost/regex.hpp>
63-
6462
#include <cmath>
6563
#include <algorithm>
6664
#include <iomanip>
65+
#include <regex>
6766

6867
using namespace QuantLib;
6968
using std::make_pair;
@@ -534,7 +533,7 @@ string SACCR::getCommodityName(const string& index, bool withPrefix) {
534533
Date expiry;
535534
if (commodity.size() > 10) {
536535
string test = commodity.substr(commodity.size() - 10);
537-
if (boost::regex_match(test, boost::regex("\\d{4}-\\d{2}-\\d{2}"))) {
536+
if (std::regex_match(test, std::regex("\\d{4}-\\d{2}-\\d{2}"))) {
538537
expiry = parseDate(test);
539538
commodity = commodity.substr(0, commodity.size() - test.size() - 1);
540539
}
@@ -543,7 +542,7 @@ string SACCR::getCommodityName(const string& index, bool withPrefix) {
543542
// Remove expiry of form NAME-YYYY-MM if NAME-YYYY-MM-DD failed
544543
if (expiry == Date() && commodity.size() > 7) {
545544
string test = commodity.substr(commodity.size() - 7);
546-
if (boost::regex_match(test, boost::regex("\\d{4}-\\d{2}"))) {
545+
if (std::regex_match(test, std::regex("\\d{4}-\\d{2}"))) {
547546
expiry = parseDate(test + "-01");
548547
commodity = commodity.substr(0, commodity.size() - test.size() - 1);
549548
}

OREAnalytics/orea/simm/crifgenerator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@
3737
#include <qle/utilities/inflation.hpp>
3838

3939
#include <boost/algorithm/string.hpp>
40-
#include <boost/regex.hpp>
4140

4241
#include <ql/tuple.hpp>
4342
#include <ql/errors.hpp>
4443

4544
#include <iomanip>
4645
#include <map>
46+
#include <regex>
4747

4848
using namespace ore::analytics;
4949

OREAnalytics/orea/simm/crifrecordgenerator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@
3737
#include <qle/utilities/inflation.hpp>
3838

3939
#include <boost/algorithm/string.hpp>
40-
#include <boost/regex.hpp>
4140
#include <ql/tuple.hpp>
4241

4342
#include <iomanip>
4443
#include <map>
44+
#include <regex>
4545

4646
using namespace ore::analytics;
4747

0 commit comments

Comments
 (0)