Skip to content

Commit

Permalink
refactor!: regress c++20 to c++17 (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
c-dilks authored Nov 21, 2023
1 parent 79505c8 commit 653bedf
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 16 deletions.
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ project(
'cpp',
version: '0.0.0',
license: 'LGPLv3',
default_options: [ 'cpp_std=c++20' ],
default_options: [ 'cpp_std=c++17' ],
)

project_inc = include_directories('src')
Expand Down
29 changes: 17 additions & 12 deletions src/algorithms/clas12/event_builder_filter/EventBuilderFilter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace iguana::clas12 {
std::set<int> acceptedRows;
for(int row = 0; row < inBanks.at("particles").getRows(); row++) {
auto pid = inBanks.at("particles").get("pid", row);
auto accept = m_opt.pids.contains(pid);
auto accept = m_opt.pids.find(pid) != m_opt.pids.end();
if(accept) acceptedRows.insert(row);
m_log->Debug("input PID {} -- accept = {}", pid, accept);
}
Expand All @@ -37,20 +37,25 @@ namespace iguana::clas12 {
switch(m_opt.mode) {

case EventBuilderFilterOptions::Modes::blank:
outBanks.at("particles").setRows(inBanks.at("particles").getRows());
for(int row = 0; row < inBanks.at("particles").getRows(); row++) {
if(acceptedRows.contains(row))
CopyBankRow(inBanks.at("particles"), row, outBanks.at("particles"), row);
else
BlankRow(outBanks.at("particles"), row);
{
outBanks.at("particles").setRows(inBanks.at("particles").getRows());
for(int row = 0; row < inBanks.at("particles").getRows(); row++) {
if(acceptedRows.find(row) != acceptedRows.end())
CopyBankRow(inBanks.at("particles"), row, outBanks.at("particles"), row);
else
BlankRow(outBanks.at("particles"), row);
}
break;
}
break;

case EventBuilderFilterOptions::Modes::compact:
outBanks.at("particles").setRows(acceptedRows.size());
for(int row = 0; auto acceptedRow : acceptedRows)
CopyBankRow(inBanks.at("particles"), acceptedRow, outBanks.at("particles"), row++);
break;
{
outBanks.at("particles").setRows(acceptedRows.size());
int row = 0;
for(auto acceptedRow : acceptedRows)
CopyBankRow(inBanks.at("particles"), acceptedRow, outBanks.at("particles"), row++);
break;
}

default:
Throw("unknown 'mode' option");
Expand Down
2 changes: 1 addition & 1 deletion src/services/Algorithm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace iguana {

bool Algorithm::MissingInputBanks(BankMap banks, std::set<std::string> keys) {
for(auto key : keys) {
if(!banks.contains(key)) {
if(banks.find(key) == banks.end()) {
m_log->Error("Algorithm '{}' is missing the input bank '{}'", m_name, key);
m_log->Error(" => the following input banks are required by '{}':", m_name);
for(auto k : keys)
Expand Down
4 changes: 2 additions & 2 deletions src/services/Logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ namespace iguana {
template <typename... VALUES>
void Print(Level lev, std::string message, VALUES... vals) {
if(lev >= m_level) {
if(m_level_names.contains(lev)) {
auto prefix = fmt::format("[{}] [{}] ", m_level_names.at(lev), m_name);
if(auto it{m_level_names.find(lev)}; it != m_level_names.end()) {
auto prefix = fmt::format("[{}] [{}] ", it->second, m_name);
fmt::print(
lev >= warn ? stderr : stdout,
fmt::runtime(prefix + message + "\n"),
Expand Down

0 comments on commit 653bedf

Please sign in to comment.