From 5508c41cbd63e221e7ed607d397d1c8991815dd0 Mon Sep 17 00:00:00 2001 From: "Ryan M. Richard" Date: Wed, 14 May 2025 22:14:07 -0500 Subject: [PATCH 1/2] backup --- include/gauxc/molecule.hpp | 8 +++++++- tests/ini_input.hpp | 4 ++-- tests/moltypes_test.cxx | 26 ++++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/include/gauxc/molecule.hpp b/include/gauxc/molecule.hpp index ebff857b..60eb873e 100644 --- a/include/gauxc/molecule.hpp +++ b/include/gauxc/molecule.hpp @@ -16,10 +16,16 @@ namespace GauXC { class Molecule : public std::vector { +private: + /// Testes if the base class can be constructed from @p Args + template + using can_construct_base_t = + std::is_constructible_v, Args...>; public: - template + template >> Molecule( Args&&... args ) : std::vector( std::forward(args)... ) { } diff --git a/tests/ini_input.hpp b/tests/ini_input.hpp index bd0de809..1577f2ee 100644 --- a/tests/ini_input.hpp +++ b/tests/ini_input.hpp @@ -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(std::isspace)))); + [](int ch) { return !std::isspace(ch); })); return s; }; // trim_left @@ -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(std::isspace))).base(), s.end()); + [](int ch) { return !std::isspace(ch); }).base(), s.end()); return s; }; // trim_right diff --git a/tests/moltypes_test.cxx b/tests/moltypes_test.cxx index f63dce91..5ed00c55 100644 --- a/tests/moltypes_test.cxx +++ b/tests/moltypes_test.cxx @@ -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") { std::vector atoms; @@ -113,6 +120,25 @@ TEST_CASE("Molecule", "[moltypes]") { } + SECTION("Copy ctor") { + + std::vector 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 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); + } } From ca849ab928d6d3be2de2385600d19ec2991e77a3 Mon Sep 17 00:00:00 2001 From: "Ryan M. Richard" Date: Wed, 14 May 2025 22:19:14 -0500 Subject: [PATCH 2/2] simpler SFINAE solution --- include/gauxc/molecule.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/gauxc/molecule.hpp b/include/gauxc/molecule.hpp index 60eb873e..ce9aaa6a 100644 --- a/include/gauxc/molecule.hpp +++ b/include/gauxc/molecule.hpp @@ -17,15 +17,15 @@ namespace GauXC { class Molecule : public std::vector { private: - /// Testes if the base class can be constructed from @p Args + /// Tests if the base class can be constructed from @p Args template - using can_construct_base_t = + static constexpr auto can_construct_base_v = std::is_constructible_v, Args...>; public: template >> + typename = std::enable_if_t>> Molecule( Args&&... args ) : std::vector( std::forward(args)... ) { }