From e37a157be5e4177b5c607abe0cd5efaf685762e1 Mon Sep 17 00:00:00 2001 From: "Vikram K. Mulligan" Date: Fri, 24 May 2024 02:24:25 -0400 Subject: [PATCH 1/2] Fixes to rdkit for cxx17 compatibility -- replace std::binary_function and std::unary_function with std::function. --- Code/DataStructs/MultiFPBReader.cpp | 8 ++++---- Code/GraphMol/Canon.cpp | 2 +- .../DistGeomHelpers/BoundsMatrixBuilder.cpp | 2 +- Code/GraphMol/FindRings.cpp | 2 +- Code/RDGeneral/Ranking.h | 8 ++++---- Code/RDGeneral/hash/extensions.hpp | 10 +++++----- Code/RDGeneral/hash/hash.hpp | 16 ++++++++-------- 7 files changed, 24 insertions(+), 24 deletions(-) diff --git a/Code/DataStructs/MultiFPBReader.cpp b/Code/DataStructs/MultiFPBReader.cpp index 9aed04cbd50..971251b4391 100644 --- a/Code/DataStructs/MultiFPBReader.cpp +++ b/Code/DataStructs/MultiFPBReader.cpp @@ -29,8 +29,8 @@ std::uint8_t *bitsetToBytes(const boost::dynamic_bitset<> &bitset); namespace { struct tplSorter - : public std::binary_function { + : public std::function { bool operator()(const MultiFPBReader::ResultTuple &v1, const MultiFPBReader::ResultTuple &v2) const { if (v1.get<0>() == v2.get<0>()) { @@ -45,8 +45,8 @@ struct tplSorter } }; struct pairSorter - : public std::binary_function, - std::pair, bool> { + : public std::function, + std::pair)> { bool operator()(const std::pair &v1, const std::pair &v2) const { if (v1.first == v2.first) { diff --git a/Code/GraphMol/Canon.cpp b/Code/GraphMol/Canon.cpp index 6d83b20547b..aa02d7262d8 100644 --- a/Code/GraphMol/Canon.cpp +++ b/Code/GraphMol/Canon.cpp @@ -81,7 +81,7 @@ bool chiralAtomNeedsTagInversion(const RDKit::ROMol &mol, } struct _possibleCompare - : public std::binary_function { + : public std::function { bool operator()(const PossibleType &arg1, const PossibleType &arg2) const { return (arg1.get<0>() < arg2.get<0>()); } diff --git a/Code/GraphMol/DistGeomHelpers/BoundsMatrixBuilder.cpp b/Code/GraphMol/DistGeomHelpers/BoundsMatrixBuilder.cpp index 3abc2b95268..7b6812216dc 100644 --- a/Code/GraphMol/DistGeomHelpers/BoundsMatrixBuilder.cpp +++ b/Code/GraphMol/DistGeomHelpers/BoundsMatrixBuilder.cpp @@ -335,7 +335,7 @@ void _setRingAngle(Atom::HybridizationType aHyb, unsigned int ringSize, } } -struct lessVector : public std::binary_function { +struct lessVector : public std::function { bool operator()(const INT_VECT &v1, const INT_VECT &v2) const { return v1.size() < v2.size(); } diff --git a/Code/GraphMol/FindRings.cpp b/Code/GraphMol/FindRings.cpp index dad1980601d..603f140fd79 100644 --- a/Code/GraphMol/FindRings.cpp +++ b/Code/GraphMol/FindRings.cpp @@ -203,7 +203,7 @@ void findSSSRforDupCands(const ROMol &mol, VECT_INT_VECT &res, } // end of loop over all set of duplicate candidates } -struct compRingSize : public std::binary_function { +struct compRingSize : public std::function { bool operator()(const INT_VECT &v1, const INT_VECT &v2) const { return v1.size() < v2.size(); } diff --git a/Code/RDGeneral/Ranking.h b/Code/RDGeneral/Ranking.h index 5f5a194a8f8..bde8353c4dc 100644 --- a/Code/RDGeneral/Ranking.h +++ b/Code/RDGeneral/Ranking.h @@ -28,7 +28,7 @@ namespace Rankers { // compared. template struct pairGreater - : public std::binary_function, std::pair, bool> { + : public std::function, std::pair) > { bool operator()(const std::pair &v1, const std::pair &v2) const { return v1.first > v2.first; @@ -39,7 +39,7 @@ struct pairGreater // compared. template struct pairLess - : public std::binary_function, std::pair, bool> { + : public std::function, std::pair ) > { bool operator()(const std::pair &v1, const std::pair &v2) const { return v1.first < v2.first; @@ -47,9 +47,9 @@ struct pairLess }; template -class argless : public std::binary_function { +class argless : public std::function { public: - argless(const T &c) : std::binary_function(), container(c){}; + argless(const T &c) : std::function(), container(c){}; bool operator()(unsigned int v1, unsigned int v2) const { return container[v1] < container[v2]; } diff --git a/Code/RDGeneral/hash/extensions.hpp b/Code/RDGeneral/hash/extensions.hpp index a438928cff6..89ae5a0033c 100644 --- a/Code/RDGeneral/hash/extensions.hpp +++ b/Code/RDGeneral/hash/extensions.hpp @@ -66,7 +66,7 @@ namespace gboost #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) template struct hash - : std::unary_function + : std::function { #if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) std::hash_result_t operator()(T const& val) const @@ -83,7 +83,7 @@ namespace gboost #if BOOST_WORKAROUND(__DMC__, <= 0x848) template struct hash - : std::unary_function + : std::function { std::hash_result_t operator()(const T* val) const { @@ -110,7 +110,7 @@ namespace gboost { template struct inner - : std::unary_function + : std::function { #if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) std::hash_result_t operator()(T const& val) const @@ -136,7 +136,7 @@ namespace gboost { template struct inner - : public std::unary_function + : public std::function { std::hash_result_t operator()(T const& val) const { @@ -155,7 +155,7 @@ namespace gboost { template struct inner - : public std::unary_function + : public std::function { std::hash_result_t operator()(T& val) const { diff --git a/Code/RDGeneral/hash/hash.hpp b/Code/RDGeneral/hash/hash.hpp index 57c056e33df..04c33da7f5d 100644 --- a/Code/RDGeneral/hash/hash.hpp +++ b/Code/RDGeneral/hash/hash.hpp @@ -374,7 +374,7 @@ namespace gboost #if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) #define BOOST_HASH_SPECIALIZE(type) \ template <> struct hash \ - : public std::unary_function \ + : public std::function \ { \ std::hash_result_t operator()(type v) const \ { \ @@ -384,7 +384,7 @@ namespace gboost #define BOOST_HASH_SPECIALIZE_REF(type) \ template <> struct hash \ - : public std::unary_function \ + : public std::function \ { \ std::hash_result_t operator()(type const& v) const \ { \ @@ -394,7 +394,7 @@ namespace gboost #else #define BOOST_HASH_SPECIALIZE(type) \ template <> struct hash \ - : public std::unary_function \ + : public std::function \ { \ std::hash_result_t operator()(type v) const \ { \ @@ -403,7 +403,7 @@ namespace gboost }; \ \ template <> struct hash \ - : public std::unary_function \ + : public std::function \ { \ std::hash_result_t operator()(const type v) const \ { \ @@ -413,7 +413,7 @@ namespace gboost #define BOOST_HASH_SPECIALIZE_REF(type) \ template <> struct hash \ - : public std::unary_function \ + : public std::function \ { \ std::hash_result_t operator()(type const& v) const \ { \ @@ -422,7 +422,7 @@ namespace gboost }; \ \ template <> struct hash \ - : public std::unary_function \ + : public std::function \ { \ std::hash_result_t operator()(type const& v) const \ { \ @@ -455,7 +455,7 @@ namespace gboost #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) template struct hash - : public std::unary_function + : public std::function { std::hash_result_t operator()(T* v) const { @@ -480,7 +480,7 @@ namespace gboost { template struct inner - : public std::unary_function + : public std::function { std::hash_result_t operator()(T val) const { From 4de2485f193270e366db4581bed601f30ea2ac56 Mon Sep 17 00:00:00 2001 From: "Vikram K. Mulligan" Date: Fri, 24 May 2024 17:33:31 -0400 Subject: [PATCH 2/2] Adding comments clearly marking stuff that was modified in the Rosetta fork of the RDKit project to allow Cxx17 compatibility while maintaining Cxx11 compatibility. These things could result in merge conflicts in the future, when the primary RDKit repo is merged into this one, and those conflicts should be resolved in favour of the primary fork. --- Code/DataStructs/MultiFPBReader.cpp | 4 ++-- Code/GraphMol/Canon.cpp | 2 +- Code/GraphMol/DistGeomHelpers/BoundsMatrixBuilder.cpp | 2 +- Code/GraphMol/FindRings.cpp | 2 +- Code/RDGeneral/Ranking.h | 8 ++++---- Code/RDGeneral/hash/extensions.hpp | 10 +++++----- Code/RDGeneral/hash/hash.hpp | 10 ++++++++-- 7 files changed, 22 insertions(+), 16 deletions(-) diff --git a/Code/DataStructs/MultiFPBReader.cpp b/Code/DataStructs/MultiFPBReader.cpp index 971251b4391..06599c73952 100644 --- a/Code/DataStructs/MultiFPBReader.cpp +++ b/Code/DataStructs/MultiFPBReader.cpp @@ -29,7 +29,7 @@ std::uint8_t *bitsetToBytes(const boost::dynamic_bitset<> &bitset); namespace { struct tplSorter - : public std::function { bool operator()(const MultiFPBReader::ResultTuple &v1, const MultiFPBReader::ResultTuple &v2) const { @@ -45,7 +45,7 @@ struct tplSorter } }; struct pairSorter - : public std::function, + : public std::function, /*Modified for Rosetta CXX17 compatibility. Resolve merge conflicts in favour of the primary RDKit repository. VKM, 24 May 2024.*/ std::pair)> { bool operator()(const std::pair &v1, const std::pair &v2) const { diff --git a/Code/GraphMol/Canon.cpp b/Code/GraphMol/Canon.cpp index aa02d7262d8..0bf392c304e 100644 --- a/Code/GraphMol/Canon.cpp +++ b/Code/GraphMol/Canon.cpp @@ -81,7 +81,7 @@ bool chiralAtomNeedsTagInversion(const RDKit::ROMol &mol, } struct _possibleCompare - : public std::function { + : public std::function { /*Modified for Rosetta CXX17 compatibility. Resolve merge conflicts in favour of the primary RDKit repository. VKM, 24 May 2024.*/ bool operator()(const PossibleType &arg1, const PossibleType &arg2) const { return (arg1.get<0>() < arg2.get<0>()); } diff --git a/Code/GraphMol/DistGeomHelpers/BoundsMatrixBuilder.cpp b/Code/GraphMol/DistGeomHelpers/BoundsMatrixBuilder.cpp index 7b6812216dc..98839de552c 100644 --- a/Code/GraphMol/DistGeomHelpers/BoundsMatrixBuilder.cpp +++ b/Code/GraphMol/DistGeomHelpers/BoundsMatrixBuilder.cpp @@ -335,7 +335,7 @@ void _setRingAngle(Atom::HybridizationType aHyb, unsigned int ringSize, } } -struct lessVector : public std::function { +struct lessVector : public std::function { /*Modified for Rosetta CXX17 compatibility. Resolve merge conflicts in favour of the primary RDKit repository. VKM, 24 May 2024.*/ bool operator()(const INT_VECT &v1, const INT_VECT &v2) const { return v1.size() < v2.size(); } diff --git a/Code/GraphMol/FindRings.cpp b/Code/GraphMol/FindRings.cpp index 603f140fd79..749a88902e8 100644 --- a/Code/GraphMol/FindRings.cpp +++ b/Code/GraphMol/FindRings.cpp @@ -203,7 +203,7 @@ void findSSSRforDupCands(const ROMol &mol, VECT_INT_VECT &res, } // end of loop over all set of duplicate candidates } -struct compRingSize : public std::function { +struct compRingSize : public std::function { /*Modified for Rosetta CXX17 compatibility. Resolve merge conflicts in favour of the primary RDKit repository. VKM, 24 May 2024.*/ bool operator()(const INT_VECT &v1, const INT_VECT &v2) const { return v1.size() < v2.size(); } diff --git a/Code/RDGeneral/Ranking.h b/Code/RDGeneral/Ranking.h index bde8353c4dc..6050fd5857d 100644 --- a/Code/RDGeneral/Ranking.h +++ b/Code/RDGeneral/Ranking.h @@ -28,7 +28,7 @@ namespace Rankers { // compared. template struct pairGreater - : public std::function, std::pair) > { + : public std::function, std::pair) > { /*Modified for Rosetta CXX17 compatibility. Resolve merge conflicts in favour of the primary RDKit repository. VKM, 24 May 2024.*/ bool operator()(const std::pair &v1, const std::pair &v2) const { return v1.first > v2.first; @@ -39,7 +39,7 @@ struct pairGreater // compared. template struct pairLess - : public std::function, std::pair ) > { + : public std::function, std::pair ) > { /*Modified for Rosetta CXX17 compatibility. Resolve merge conflicts in favour of the primary RDKit repository. VKM, 24 May 2024.*/ bool operator()(const std::pair &v1, const std::pair &v2) const { return v1.first < v2.first; @@ -47,9 +47,9 @@ struct pairLess }; template -class argless : public std::function { +class argless : public std::function { /*Modified for Rosetta CXX17 compatibility. Resolve merge conflicts in favour of the primary RDKit repository. VKM, 24 May 2024.*/ public: - argless(const T &c) : std::function(), container(c){}; + argless(const T &c) : std::function(), container(c){}; /*Modified for Rosetta CXX17 compatibility. Resolve merge conflicts in favour of the primary RDKit repository. VKM, 24 May 2024.*/ bool operator()(unsigned int v1, unsigned int v2) const { return container[v1] < container[v2]; } diff --git a/Code/RDGeneral/hash/extensions.hpp b/Code/RDGeneral/hash/extensions.hpp index 89ae5a0033c..e04a6c056c5 100644 --- a/Code/RDGeneral/hash/extensions.hpp +++ b/Code/RDGeneral/hash/extensions.hpp @@ -66,7 +66,7 @@ namespace gboost #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) template struct hash - : std::function + : std::function /*Modified for Rosetta CXX17 compatibility. Resolve merge conflicts in favour of the primary RDKit repository. VKM, 24 May 2024.*/ { #if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) std::hash_result_t operator()(T const& val) const @@ -83,7 +83,7 @@ namespace gboost #if BOOST_WORKAROUND(__DMC__, <= 0x848) template struct hash - : std::function + : std::function /*Modified for Rosetta CXX17 compatibility. Resolve merge conflicts in favour of the primary RDKit repository. VKM, 24 May 2024.*/ { std::hash_result_t operator()(const T* val) const { @@ -110,7 +110,7 @@ namespace gboost { template struct inner - : std::function + : std::function /*Modified for Rosetta CXX17 compatibility. Resolve merge conflicts in favour of the primary RDKit repository. VKM, 24 May 2024.*/ { #if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) std::hash_result_t operator()(T const& val) const @@ -136,7 +136,7 @@ namespace gboost { template struct inner - : public std::function + : public std::function /*Modified for Rosetta CXX17 compatibility. Resolve merge conflicts in favour of the primary RDKit repository. VKM, 24 May 2024.*/ { std::hash_result_t operator()(T const& val) const { @@ -155,7 +155,7 @@ namespace gboost { template struct inner - : public std::function + : public std::function /*Modified for Rosetta CXX17 compatibility. Resolve merge conflicts in favour of the primary RDKit repository. VKM, 24 May 2024.*/ { std::hash_result_t operator()(T& val) const { diff --git a/Code/RDGeneral/hash/hash.hpp b/Code/RDGeneral/hash/hash.hpp index 04c33da7f5d..d7fb5dafe0a 100644 --- a/Code/RDGeneral/hash/hash.hpp +++ b/Code/RDGeneral/hash/hash.hpp @@ -372,6 +372,8 @@ namespace gboost // #if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) + +/*Modified for Rosetta CXX17 compatibility. Resolve merge conflicts in favour of the primary RDKit repository. VKM, 24 May 2024.*/ #define BOOST_HASH_SPECIALIZE(type) \ template <> struct hash \ : public std::function \ @@ -382,6 +384,7 @@ namespace gboost } \ }; +/*Modified for Rosetta CXX17 compatibility. Resolve merge conflicts in favour of the primary RDKit repository. VKM, 24 May 2024.*/ #define BOOST_HASH_SPECIALIZE_REF(type) \ template <> struct hash \ : public std::function \ @@ -392,6 +395,8 @@ namespace gboost } \ }; #else + +/*Modified for Rosetta CXX17 compatibility. Resolve merge conflicts in favour of the primary RDKit repository. VKM, 24 May 2024.*/ #define BOOST_HASH_SPECIALIZE(type) \ template <> struct hash \ : public std::function \ @@ -411,6 +416,7 @@ namespace gboost } \ }; +/*Modified for Rosetta CXX17 compatibility. Resolve merge conflicts in favour of the primary RDKit repository. VKM, 24 May 2024.*/ #define BOOST_HASH_SPECIALIZE_REF(type) \ template <> struct hash \ : public std::function \ @@ -455,7 +461,7 @@ namespace gboost #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) template struct hash - : public std::function + : public std::function /*Modified for Rosetta CXX17 compatibility. Resolve merge conflicts in favour of the primary RDKit repository. VKM, 24 May 2024.*/ { std::hash_result_t operator()(T* v) const { @@ -480,7 +486,7 @@ namespace gboost { template struct inner - : public std::function + : public std::function /*Modified for Rosetta CXX17 compatibility. Resolve merge conflicts in favour of the primary RDKit repository. VKM, 24 May 2024.*/ { std::hash_result_t operator()(T val) const {