From 5090a4959ce42ced1f88d400a7a4f70b8bd5af95 Mon Sep 17 00:00:00 2001
From: Gabriel Studer <gabriel.studer@unibas.ch>
Date: Mon, 22 Aug 2022 09:57:33 +0200
Subject: [PATCH] silence deprecation warning - boost bind

Many of them remain, as they're triggered by Boost code too. Specifically
when importing boost python. Relevant Github discussion:
https://github.com/boostorg/python/issues/359
---
 modules/gfx/src/gfx_node.cc               |  8 ++++----
 modules/gfx/src/scene.cc                  | 18 +++++++++---------
 modules/io/src/img/map_io_jpk_handler.cc  |  1 -
 modules/io/src/img/map_io_tiff_handler.cc |  1 -
 modules/io/src/mol/sdf_writer.cc          |  5 +++--
 modules/mol/alg/src/svd_superpose.cc      |  2 --
 modules/mol/base/src/chain_view.cc        |  9 ++++-----
 modules/mol/base/src/entity_view.cc       |  7 +++----
 modules/mol/base/src/impl/atom_impl.cc    |  5 ++---
 modules/mol/base/src/impl/chain_impl.cc   |  7 +++----
 modules/mol/base/src/impl/residue_impl.cc |  2 --
 modules/mol/base/src/residue_view.cc      |  9 ++++-----
 modules/seq/base/src/sequence_op.cc       |  2 --
 13 files changed, 32 insertions(+), 44 deletions(-)

diff --git a/modules/gfx/src/gfx_node.cc b/modules/gfx/src/gfx_node.cc
index 716523f1d..3923eb735 100644
--- a/modules/gfx/src/gfx_node.cc
+++ b/modules/gfx/src/gfx_node.cc
@@ -16,7 +16,7 @@
 // along with this library; if not, write to the Free Software Foundation, Inc.,
 // 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 //------------------------------------------------------------------------------
-#include <boost/bind.hpp>
+#include <boost/bind/bind.hpp>
 #include <ost/dyn_cast.hh>
 
 #include "gfx_node.hh"
@@ -156,7 +156,7 @@ void GfxNode::Remove(GfxObjP obj)
     obj->parent_.reset();
     if (this->IsAttachedToScene()) {
       Scene::Instance().NotifyObservers(bind(&SceneObserver::NodeRemoved, 
-                                             _1, obj));
+                                             boost::placeholders::_1, obj));
     }    
   }
 
@@ -174,7 +174,7 @@ void GfxNode::RemoveAll()
     if (!attached) 
       continue;
     Scene::Instance().NotifyObservers(bind(&SceneObserver::NodeRemoved, 
-                                           _1, *i));
+                                           boost::placeholders::_1, *i));
   }
   node_vector_.clear();
 }
@@ -211,7 +211,7 @@ void GfxNode::Remove(GfxNodeP node)
   }
   if (this->IsAttachedToScene()) {
     Scene::Instance().NotifyObservers(bind(&SceneObserver::NodeRemoved, 
-                                           _1, node));
+                                           boost::placeholders::_1, node));
   }
 }
 
diff --git a/modules/gfx/src/scene.cc b/modules/gfx/src/scene.cc
index a6fbd0d68..1774cb72f 100644
--- a/modules/gfx/src/scene.cc
+++ b/modules/gfx/src/scene.cc
@@ -30,7 +30,7 @@
 #include <sys/time.h>
 #endif
 
-#include <boost/bind.hpp>
+#include <boost/bind/bind.hpp>
 #include <boost/shared_array.hpp>
 #include <boost/filesystem/operations.hpp>
 #include <boost/filesystem/fstream.hpp>
@@ -995,7 +995,7 @@ bool Scene::IsNameAvailable(const String& name) const
 
 void Scene::NodeAdded(const GfxNodeP& node)
 {
-  this->NotifyObservers(bind(&SceneObserver::NodeAdded, _1, node));
+  this->NotifyObservers(bind(&SceneObserver::NodeAdded, boost::placeholders::_1, node));
 }
 
 void Scene::ObjectChanged(const String& name)
@@ -1003,13 +1003,13 @@ void Scene::ObjectChanged(const String& name)
   FindObj fn(name);
   Apply(fn);
   if(fn.node) {
-    this->NotifyObservers(bind(&SceneObserver::NodeChanged, _1, fn.node));
+    this->NotifyObservers(bind(&SceneObserver::NodeChanged, boost::placeholders::_1, fn.node));
   }
 }
 
 void Scene::NodeTransformed(const GfxObjP& object)
 {
-  this->NotifyObservers(bind(&SceneObserver::NodeTransformed, _1, object));
+  this->NotifyObservers(bind(&SceneObserver::NodeTransformed, boost::placeholders::_1, object));
 }
 
 void Scene::SelectionChanged(const String& name, const mol::EntityView& sel)
@@ -1017,7 +1017,7 @@ void Scene::SelectionChanged(const String& name, const mol::EntityView& sel)
   FindObj fn(name);
   Apply(fn);
   if(fn.node) {
-    this->NotifyObservers(bind(&SceneObserver::SelectionChanged, _1, fn.node, sel));
+    this->NotifyObservers(bind(&SceneObserver::SelectionChanged, boost::placeholders::_1, fn.node, sel));
   }
 }
 
@@ -1026,7 +1026,7 @@ void Scene::RenderModeChanged(const String& name)
   FindObj fn(name);
   Apply(fn);
   if(fn.node) {
-    this->NotifyObservers(bind(&SceneObserver::RenderModeChanged, _1, fn.node));
+    this->NotifyObservers(bind(&SceneObserver::RenderModeChanged, boost::placeholders::_1, fn.node));
   }
 }
 
@@ -1034,7 +1034,7 @@ void Scene::Remove(const GfxNodeP& go)
 {
   if(!go) return;
   root_node_->Remove(go);
-  this->NotifyObservers(bind(&SceneObserver::NodeRemoved, _1,go));
+  this->NotifyObservers(bind(&SceneObserver::NodeRemoved, boost::placeholders::_1,go));
 }
 
 void Scene::RemoveAll()
@@ -1050,7 +1050,7 @@ void Scene::Remove(const String& name)
   if(fn.node) {
     root_node_->Remove(name);
     if(GfxObjP go = dyn_cast<GfxObj>(fn.node)) {
-      this->NotifyObservers(bind(&SceneObserver::NodeRemoved, _1, go));
+      this->NotifyObservers(bind(&SceneObserver::NodeRemoved, boost::placeholders::_1, go));
     }
   }
 }
@@ -1610,7 +1610,7 @@ void Scene::SetSelectionMode(uint m)
 {
   if (selection_mode_!=m) {
     selection_mode_=m;
-    this->NotifyObservers(bind(&SceneObserver::SelectionModeChanged, _1,
+    this->NotifyObservers(bind(&SceneObserver::SelectionModeChanged, boost::placeholders::_1,
                                selection_mode_));
   }
 
diff --git a/modules/io/src/img/map_io_jpk_handler.cc b/modules/io/src/img/map_io_jpk_handler.cc
index 3225ef871..58922e541 100644
--- a/modules/io/src/img/map_io_jpk_handler.cc
+++ b/modules/io/src/img/map_io_jpk_handler.cc
@@ -32,7 +32,6 @@
 #include <ost/io/io_exception.hh>
 
 #include <boost/function.hpp>
-#include <boost/bind.hpp>
 
 #include "jpk_util.hh"
 #include "tiff_util.hh"
diff --git a/modules/io/src/img/map_io_tiff_handler.cc b/modules/io/src/img/map_io_tiff_handler.cc
index d88fc01d7..fbabb0cf6 100644
--- a/modules/io/src/img/map_io_tiff_handler.cc
+++ b/modules/io/src/img/map_io_tiff_handler.cc
@@ -29,7 +29,6 @@
 #include <stdarg.h>
 
 #include <boost/function.hpp>
-#include <boost/bind.hpp>
 
 #include <ost/img/image_state.hh>
 #include <ost/img/progress.hh>
diff --git a/modules/io/src/mol/sdf_writer.cc b/modules/io/src/mol/sdf_writer.cc
index ff14d0fd5..8deaf9a78 100644
--- a/modules/io/src/mol/sdf_writer.cc
+++ b/modules/io/src/mol/sdf_writer.cc
@@ -28,7 +28,7 @@
 #include <ost/mol/chain_view.hh>
 #include <ost/mol/bond_handle.hh>
 #include <boost/regex.hpp>
-#include <boost/bind.hpp>
+#include <boost/bind/bind.hpp>
 
 namespace ost { namespace io {
 
@@ -100,7 +100,8 @@ namespace {
       // get all neighboring atoms and sort them according to their atom index
       mol::AtomViewList atoms = atom.GetBondPartners();
       std::sort(atoms.begin(), atoms.end(), bind(&SDFBondWriter::CompareAtomIdx,
-                                                 this, _1, _2));
+                                                 this, boost::placeholders::_1,
+                                                 boost::placeholders::_2));
 
       // iterate all neighboring atoms and print bonds to all atoms with index
       // larger than current atom index
diff --git a/modules/mol/alg/src/svd_superpose.cc b/modules/mol/alg/src/svd_superpose.cc
index 6780213cf..bbf35c24d 100644
--- a/modules/mol/alg/src/svd_superpose.cc
+++ b/modules/mol/alg/src/svd_superpose.cc
@@ -19,7 +19,6 @@
 
 #include <stdexcept>
 #include <iostream>
-#include <boost/bind.hpp>
 
 #include <Eigen/SVD>
 #include <Eigen/Geometry>
@@ -39,7 +38,6 @@
 namespace ost { namespace mol { namespace alg {
 
 
-using boost::bind;
 typedef Eigen::Matrix<Real,3,1> EVec3;
 typedef Eigen::Matrix<Real,3,3> EMat3;
 typedef Eigen::Matrix<Real,4,4> EMat4;
diff --git a/modules/mol/base/src/chain_view.cc b/modules/mol/base/src/chain_view.cc
index 96c038460..e0c5b5dce 100644
--- a/modules/mol/base/src/chain_view.cc
+++ b/modules/mol/base/src/chain_view.cc
@@ -18,7 +18,7 @@
 //------------------------------------------------------------------------------
 #include <algorithm>
 #include <limits>
-#include <boost/bind.hpp>
+#include <boost/bind/bind.hpp>
 #include <ost/log.hh>
 #include <ost/mol/bond_handle.hh>
 #include <ost/mol/residue_handle.hh>
@@ -31,7 +31,6 @@
 #include <ost/mol/impl/chain_impl.hh>
 #include <ost/mol/entity_handle.hh>
 
-using boost::bind;
 
 namespace ost { namespace mol {
 
@@ -182,7 +181,7 @@ ResidueView ChainView::FindResidue(const ResNum& number) const {
     return ResidueView();
   } else {
     i=std::find_if(l.begin(), l.end(), 
-                   bind(&ResidueView::GetNumber, _1)==number);
+                   bind(&ResidueView::GetNumber, boost::placeholders::_1)==number);
     return i==data_->residues.end() ? ResidueView() : *i;    
   }
 }
@@ -310,7 +309,7 @@ ResidueView ChainView::AddResidue(const ResidueView& residue_view,
 void ChainView::RemoveResidues() {
   this->CheckValidity();
   std::for_each(data_->residues.begin(), data_->residues.end(),
-                bind(&ResidueView::RemoveAtoms, _1));
+                bind(&ResidueView::RemoveAtoms, boost::placeholders::_1));
   data_->residues.clear();
   data_->handle_to_view.clear();
 }
@@ -340,7 +339,7 @@ int ChainView::GetResidueIndex(const ResNum& number) const
     i=p.first;
   } else {
     i=std::find_if(data_->residues.begin(), data_->residues.end(),
-                   bind(&ResidueView::GetNumber, _1)==number);    
+                   bind(&ResidueView::GetNumber, boost::placeholders::_1)==number);    
   }
 
   return i==data_->residues.end() ? -1 : i-data_->residues.begin();
diff --git a/modules/mol/base/src/entity_view.cc b/modules/mol/base/src/entity_view.cc
index 26cfa75e3..c28b7aae5 100644
--- a/modules/mol/base/src/entity_view.cc
+++ b/modules/mol/base/src/entity_view.cc
@@ -22,7 +22,7 @@
  */
 #include <algorithm>
 
-#include <boost/bind.hpp>
+#include <boost/bind/bind.hpp>
 #include <boost/logic/tribool.hpp>
 
 #include <ost/log.hh>
@@ -44,7 +44,6 @@
 
 using boost::logic::tribool;
 using boost::logic::indeterminate;
-using boost::bind;
 
 
 
@@ -266,7 +265,7 @@ ChainView EntityView::FindChain(const String& chain_name) const{
   this->CheckValidity();
   ChainViewList::const_iterator i;
   i=std::find_if(data_->chains.begin(), data_->chains.end(),
-                 boost::bind(&ChainView::GetName, _1)==chain_name);
+                 boost::bind(&ChainView::GetName, boost::placeholders::_1)==chain_name);
   return (i!=data_->chains.end()) ? *i : ChainView();
 }
 
@@ -428,7 +427,7 @@ ChainView EntityView::ViewForHandle(const ChainHandle& chain) const {
   this->CheckValidity();
   ChainViewList::const_iterator i;
   i=std::find_if(data_->chains.begin(), data_->chains.end(),
-                 bind(&ChainView::GetHandle, _1)==chain);
+                 bind(&ChainView::GetHandle, boost::placeholders::_1)==chain);
   return (i!=data_->chains.end()) ? *i : ChainView();
 }
 
diff --git a/modules/mol/base/src/impl/atom_impl.cc b/modules/mol/base/src/impl/atom_impl.cc
index 73d0d5e6a..9c5642eaf 100644
--- a/modules/mol/base/src/impl/atom_impl.cc
+++ b/modules/mol/base/src/impl/atom_impl.cc
@@ -29,10 +29,9 @@
 #include "chain_impl.hh"
 #include "torsion_impl.hh"
 #include <ost/mol/entity_visitor.hh>
-#include <boost/bind.hpp>
+#include <boost/bind/bind.hpp>
 #include <algorithm>
 
-using boost::bind;
 
 namespace ost {  namespace mol { namespace impl {
 
@@ -375,7 +374,7 @@ void AtomImpl::DeleteAllTorsions() {
     TorsionImplList& l = (*i)->GetTorsionList();
     TorsionImplList::iterator j;
     j=std::remove_if(l.begin(), l.end(),
-                     bind(&TorsionImpl::IsAtomInvolved, _1, shared_from_this()));
+                     bind(&TorsionImpl::IsAtomInvolved, boost::placeholders::_1, shared_from_this()));
     l.erase(j, l.end());
   }
 }
diff --git a/modules/mol/base/src/impl/chain_impl.cc b/modules/mol/base/src/impl/chain_impl.cc
index d07bc6436..ca2aeaad7 100644
--- a/modules/mol/base/src/impl/chain_impl.cc
+++ b/modules/mol/base/src/impl/chain_impl.cc
@@ -23,11 +23,10 @@
 #include "entity_impl.hh"
 #include <ost/mol/impl/atom_impl.hh>
 #include <ost/mol/entity_visitor.hh>
-#include <boost/bind.hpp>
+#include <boost/bind/bind.hpp>
 #include <algorithm>
 #include <numeric>
 
-using boost::bind;
 using std::accumulate;
 
 namespace ost { namespace mol { namespace impl {
@@ -380,7 +379,7 @@ int ChainImpl::GetIndexForResNum(const ResNum& number) const
       ResidueImplList::const_iterator k;    
       k=std::find_if(residue_list_.begin(), 
                      residue_list_.end(), 
-                     bind(&ResidueImpl::GetNumber, _1)==number);
+                     bind(&ResidueImpl::GetNumber, boost::placeholders::_1)==number);
 
       if (k==residue_list_.end())
         return -1;
@@ -426,7 +425,7 @@ int ChainImpl::GetIndex(const ResidueImplPtr& res) const
       ResidueImplList::const_iterator k=residue_list_.begin()-1;
       do {
         k=std::find_if(k+1, residue_list_.end(), 
-                       bind(&ResidueImpl::GetNumber, _1)==number);
+                       bind(&ResidueImpl::GetNumber, boost::placeholders::_1)==number);
       } while(k!=residue_list_.end() && (*k)!=res);
 
       if (k==residue_list_.end())
diff --git a/modules/mol/base/src/impl/residue_impl.cc b/modules/mol/base/src/impl/residue_impl.cc
index c4ddfbe36..819c7294d 100644
--- a/modules/mol/base/src/impl/residue_impl.cc
+++ b/modules/mol/base/src/impl/residue_impl.cc
@@ -23,12 +23,10 @@
 #include "residue_impl.hh"
 #include "atom_impl.hh"
 #include "entity_impl.hh"
-#include <boost/bind.hpp>
 #include <algorithm>
 #include "torsion_impl.hh"
 #include <ost/mol/impl/connector_impl.hh>
 
-using boost::bind;
 
 namespace ost { namespace mol { namespace impl {
 
diff --git a/modules/mol/base/src/residue_view.cc b/modules/mol/base/src/residue_view.cc
index ee463fe1a..db5503407 100644
--- a/modules/mol/base/src/residue_view.cc
+++ b/modules/mol/base/src/residue_view.cc
@@ -19,7 +19,7 @@
 #include <algorithm>
 #include <limits>
 
-#include <boost/bind.hpp>
+#include <boost/bind/bind.hpp>
 #include <ost/log.hh>
 #include <ost/mol/bond_handle.hh>
 #include <ost/mol/chain_view.hh>
@@ -32,7 +32,6 @@
 #include "residue_view.hh"
 #include "residue_handle.hh"
 
-using boost::bind;
 
 namespace ost { namespace mol {
 
@@ -114,7 +113,7 @@ AtomView ResidueView::FindAtom(const String& atom_name) const {
   this->CheckValidity();
   const AtomViewList& l=data_->atoms;
   AtomViewList::const_iterator i;
-  i=std::find_if(l.begin(), l.end(), boost::bind(&AtomView::GetName, _1)==atom_name);
+  i=std::find_if(l.begin(), l.end(), boost::bind(&AtomView::GetName, boost::placeholders::_1)==atom_name);
   return i==data_->atoms.end() ? AtomView() : *i;
 }
 
@@ -122,7 +121,7 @@ AtomView ResidueView::ViewForHandle(const AtomHandle& handle) const {
   this->CheckValidity();
   const AtomViewList& l=data_->atoms;
   AtomViewList::const_iterator i;
-  i=std::find_if(l.begin(), l.end(), bind(&AtomView::GetHandle, _1)==handle);
+  i=std::find_if(l.begin(), l.end(), bind(&AtomView::GetHandle, boost::placeholders::_1)==handle);
   return i==data_->atoms.end() ? AtomView() : *i;
 }
 
@@ -166,7 +165,7 @@ void ResidueView::RemoveAtoms()
 {
   this->CheckValidity();
   std::for_each(data_->atoms.begin(), data_->atoms.end(),
-                bind(&AtomView::RemoveBonds, _1));
+                bind(&AtomView::RemoveBonds, boost::placeholders::_1));
   AtomViewList::iterator i;
   EntityView ev=this->GetEntity();
   for (i=data_->atoms.begin(); i!=data_->atoms.end(); ++i) {
diff --git a/modules/seq/base/src/sequence_op.cc b/modules/seq/base/src/sequence_op.cc
index b6a5dfda5..3bf3efaab 100644
--- a/modules/seq/base/src/sequence_op.cc
+++ b/modules/seq/base/src/sequence_op.cc
@@ -19,14 +19,12 @@
 #include <sstream>
 #include <numeric>
 
-#include <boost/bind.hpp>
 
 #include <ost/mol/mol.hh>
 
 #include "sequence_op.hh"
 
 
-using boost::bind;
 
 namespace ost { namespace seq {
 
-- 
GitLab