Skip to content

Commit

Permalink
refactor(fmt/sdf): cast inside factory
Browse files Browse the repository at this point in the history
  • Loading branch information
jnooree committed Oct 18, 2024
1 parent 9ea04ae commit db5fc7c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/fmt/sdf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,12 @@ namespace x3 = boost::spirit::x3;
using Iterator = std::vector<std::string>::const_iterator;

struct HeaderReadResult {
static HeaderReadResult failure() { return HeaderReadResult(); }
static HeaderReadResult failure() { return {}; }

static HeaderReadResult success(int version, int natoms, int nbonds) {
return HeaderReadResult(version, natoms, nbonds);
template <class N1, class N2, class N3>
static HeaderReadResult success(N1 version, N2 natoms, N3 nbonds) {
return { static_cast<int>(version), static_cast<int>(natoms),
static_cast<int>(nbonds) };
}

int version() const { return version_; }
Expand Down Expand Up @@ -661,8 +663,7 @@ bool try_read_v3000_header(HeaderReadResult &metadata, Iterator &it,

ABSL_DCHECK(counts.size() >= 2);

metadata = HeaderReadResult::success(3000, static_cast<int>(counts[0]),
static_cast<int>(counts[1]));
metadata = HeaderReadResult::success(3000, counts[0], counts[1]);
return true;
}

Expand Down

0 comments on commit db5fc7c

Please sign in to comment.