Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion include/gauxc/molecule.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,16 @@
namespace GauXC {

class Molecule : public std::vector<Atom> {
private:
/// Tests if the base class can be constructed from @p Args
template <typename... Args>
static constexpr auto can_construct_base_v =
std::is_constructible_v<std::vector<Atom>, Args...>;

public:

template <typename... Args>
template <typename... Args,
typename = std::enable_if_t<can_construct_base_v<Args...>>>
Molecule( Args&&... args ) :
std::vector<Atom>( std::forward<Args>(args)... ) { }

Expand Down
4 changes: 2 additions & 2 deletions tests/ini_input.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/
static inline std::string& trim_left(std::string &s) {
s.erase(s.begin(), std::find_if(s.begin(), s.end(),
std::not1(std::ptr_fun<int, int>(std::isspace))));
[](int ch) { return !std::isspace(ch); }));
return s;
}; // trim_left

Expand All @@ -36,7 +36,7 @@ static inline std::string& trim_left(std::string &s) {
*/
static inline std::string& trim_right(std::string &s) {
s.erase(std::find_if(s.rbegin(), s.rend(),
std::not1(std::ptr_fun<int, int>(std::isspace))).base(), s.end());
[](int ch) { return !std::isspace(ch); }).base(), s.end());
return s;
}; // trim_right

Expand Down
26 changes: 26 additions & 0 deletions tests/moltypes_test.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ TEST_CASE("Molecule", "[moltypes]") {

size_t natoms_gen = 40;

SECTION("Default") {

Molecule mol;

CHECK(mol.natoms() == 0);
}

SECTION("From std::vector<Atom>") {

std::vector<Atom> atoms;
Expand Down Expand Up @@ -113,6 +120,25 @@ TEST_CASE("Molecule", "[moltypes]") {

}

SECTION("Copy ctor") {

std::vector<Atom> atoms{Atom(AtomicNumber(1), 0.0, 0.0, 0.0)};
Molecule mol(atoms);

Molecule mol_copy(mol);
CHECK(mol == mol_copy);
}


SECTION("Move ctor") {

std::vector<Atom> atoms{Atom(AtomicNumber(1), 0.0, 0.0, 0.0)};
Molecule mol(atoms);

Molecule mol_copy(mol);
Molecule mol_move(std::move(mol));
CHECK(mol_move == mol_copy);
}

}

Expand Down